Welcome to WebmasterWorld Guest from 54.145.105.173

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to explode data and delete one line?

     
12:57 pm on May 13, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Oct 25, 2006
posts: 1006
votes: 0


I have code like:
$databasedata = '/*space*/text/*space*/|';
$mydata = explode("|", $databasedata);

When I explode it will be one space after word like
blabla /*space*/

Notice: data from which are exloded have also space.

How to delete this space with one line?
1:06 am on May 16, 2011 (gmt 0)

New User

10+ Year Member

joined:Sept 19, 2003
posts: 22
votes: 0


The trim() function should work if I understand your question correctly.
7:50 am on May 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Oct 25, 2006
posts: 1006
votes: 0


thank you.

So, this will work?
The SPACE at the beginning of the string
$string=" eggs sold here";
$newstring=ltrim($string," "); // left trim

The above will output:eggs sold her
10:29 am on May 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Oct 25, 2006
posts: 1006
votes: 0


This works.
Can be just ONE line with this code as I have line to lower characters:


$var[$i] = mb_strtolower($element, 'UTF-8');
$var[$i] =rtrim($element," "); // right trim