Welcome to WebmasterWorld Guest from 54.226.194.180

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to explode data and delete one line?

     

toplisek

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

WebmasterWorld Senior Member 5+ Year Member



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?

Finger

1:06 am on May 16, 2011 (gmt 0)

10+ Year Member



The trim() function should work if I understand your question correctly.

toplisek

7:50 am on May 16, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

toplisek

10:29 am on May 16, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month