Click to See Complete Forum and Search --> : substr returning just the first char


YoN
10-30-2003, 03:42 PM
Hi,
Does anyone know why substr would return just the first character of a string in the code below?

$lang = substr($_GET["lang"], 0, 2);

f.i. if $_GET["lang"] is english the code sets $lang to e.

it's supposed to set $lang to the two first characters, isn't it?:confused:... at localhost (PHP 4.3.3) it works just fine but at the server (PHP 4.3.2) it doesn't.

Thanks in advance.

YoN
10-30-2003, 04:07 PM
I changed $_GET array with an equivalent $variable and it's working now :D
perhaps substr doesn't work fine with arrays, a bug fixed in PHP 4.3.3
Thanks.