Hello, I have a curios problem sorting an array with numbers with leading zeroes as either numeric or string.
Here is my array:
$target[] = array('06', '14', '24', '35', '37', '49');
$target[] = array('06', '23', '37', '44', '48', '49');
$target[] = array('06', '10', '14', '22', '44', '49');
$target[] = array('01', '06', '14', '36', '37', '44');
$target[] = array('14', '18', '19', '29', '37', '49');
$target[] = array('18', '06', '09', '44', '14', '30');
I tried using methods SORT_NUMERIC and SORT_STRING as follows:
sort($target, SORT_NUMERIC);
and in the last array, I see this:
5 =>
array (size=6)
0 => string '18' (length=2)
1 => string '06' (length=2)
2 => string '09' (length=2)
3 => string '44' (length=2)
4 => string '14' (length=2)
5 => string '30' (length=2)
I tried manually editing to correct the array but still see the same result.
I also tried to cast the values to integer as follows but again still see the same result:
// Cast all values in array as integer type values otherwise leave as strings
$passmydraws === array_merge(array($target[0]),array_map('intval', array_slice($target, 0, 5))); // strval intval
echo "Cast all values in passmydraws <pre>"; var_dump($target); echo "</pre>"; echo "<br>\n";
What am I missing or how can I remove the leading zeroes from the entire array if that will help?