Something really strange is happening so I have the string "0201506 -" and I want to split this into 3 parts like the first part are the 2 first numbers (02), the second part are the numbers 01 and finally the last number will be 506 (the last three digits.
In order to do this I'm doing substr but is not doing right for the second part,
$lr = $request->input('lrSelect');
echo "select lr ---> " . $lr . "
";
$codConcelho = substr($lr, 2,3);
$codLR = substr($lr, 4,6);
echo "second---> " . $codConcelho . "
";
echo "last ---> " . $codLR . "
";
the output is
second ---> 015 last ---> 506 -
I want to have
"second" = 01 and "last" = 506.
What am I doing wrong?
I'm counting the first number as position 0 (start)...
Thanks to @Chris White I found the problem was my length parameter.. I've change my code to
$codConcelho=substr($lr, 2,2);
$codLR=substr($lr, 4,3);
And it worked... I was thinking the last parameter was the end position of the char and not the length of substring...