Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to trim a string value?

Posted on 2002-04-07
1
Medium Priority
?
263 Views
Last Modified: 2012-05-04
hai,

I have a text file which I need to upload in to the server& later parse in to db.
In the txt file the fields r separated by , & enclosed by
".

I can split the values in txt file using explode fn.
$piece=explode(",",$fcontents[$i]);//where $fcontents contains the text file loaded in to the server.

b4 parsing in to db, I try to trim the function to eliminate "(double quotes) by below coding

strlen(trim($piece[0]))==13;

but still I could see values with double quotes when I try to display it in the browser b4 parsing.

can anyone guide me on how to prevent double quotes from being displayed.

thank you,
harish





0
Comment
Question by:harishsai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
nfuids earned 90 total points
ID: 6924535
trim won't take the " out.. trim takes spaces out of the variable..

try str_replace or ereg_replace ..
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question