0

i've a problem with "/anystring" and ltrim function in php.

here's my code:

$s = "/ciao/come/va";

$s1 = ltrim($s,'/ciao');

echo $s1;

i want $s1 return "/come/va" but the code always returns "me/va" I've already test other solution but i need to use ltrim.

Giuseppe Lodi Rizzini
  • 1,045
  • 11
  • 33
  • Did you think about explode function? – patwoj98 Mar 04 '16 at 09:11
  • if your format fix like this $s = "/ciao/come/va"; than you will do it in this way $s = "/ciao/come/va"; $s1 = explode("/", $s); unset($s1[0]); unset($s1[1]); $s2 = implode("/", $s1); echo $s2; beacuse when you use ltrim and set character it will search "c" and "o" from other line and remove it also must read and see examples carefully and you will get idea why its behave like this http://php.net/manual/en/function.ltrim.php – jilesh Mar 04 '16 at 09:13

0 Answers0