i have to split a substring from a string how do it? my requirement is i have a variable $var =,1,4,7 out put should be like $var =1,4,7(split first comma from the value. thanz in advance fernandodonster is online now Edit/Delete Message
You could try [man]stripos[/man] to locate the comma, then [man]substr[/man] to split it. There are probably better ways to do it, but none that I know of.
Hi, if you need to remove the first character from the string: from the manual : [man]substr[/man] echo substr('abcdef', 1); // bcdef
[man]ltrim[/man] may be another option as long as you do not mind that whitespace characters would be stripped as well if there were any at the beginning of the string.
echo ltrim($var, ',');
If you supply a list of characters, trim/ltrim/rtrim will only trim whitespace if whitespace characters are in the list.
Thank you for correcting me. I wasn't aware and didn't look at the manual close enough myself.