Sunday, 15 January 2012

Php trim string at a particular character -


Is a php string function to trim a string after a particular character? I put a look at the php.net site and did a Google search, but found nothing. I could imagine that the only solution exploded and then grab the first part of the array, but this is not the most elegant solution.

For example

  $ string = "/ Gallery / image? A = b"; $ String = Fictional _ work ($ string, '?'); Echo $ string; // echoes "/ gallery / image"  

Does a php string detect a good cheat sheet for manipulation tasks? Thank you

You can use:

  $ string = " / Gallery? / Image a = b "; List ($ url, $ querystring) = explosion ('?', $ String, 2);  

No comments:

Post a Comment