<code>$array = array('0'=>'3','1','2','a'=>'a','b'=>'b','c'=>'c') </code>
Question 1:
Assign the previous indexes 0, 1, 2 to the $int array, and allocate the English keys such as a, b, c to the $string array.
Distinguish between 0, 1, 2 and English keys I don’t know how to deal with the problem because they are all string types? (solved)
Question 2:
<code>第一个数组: array (size=3) 0 => string '3' (length=1) 1 => string '1' (length=1) 2 => string '2' (length=1) 第二个数组: array (size=3) 0 => array (size=1) 'a' => string 'a' (length=1) 1 => array (size=1) 'b' => string 'b' (length=1) 2 => array (size=1) 'c' => string 'c' (length=1)</code>
After var_dump, I used array_push for the second array, but I hope the index is not in numbers, but directly in English,
as follows:
<code>array (size=3) 'a' => string '3' (length=1) 'b' => string '1' (length=1) 'c' => string '2' (length=1) </code>
<code>$array = array('0'=>'3','1','2','a'=>'a','b'=>'b','c'=>'c') </code>
Question 1:
Assign the previous indexes 0, 1, 2 to the $int array, and allocate the English keys such as a, b, c to the $string array.
Distinguish between 0, 1, 2 and English keys I don’t know how to deal with the problem because they are all string types? (solved)
Question 2:
<code>第一个数组: array (size=3) 0 => string '3' (length=1) 1 => string '1' (length=1) 2 => string '2' (length=1) 第二个数组: array (size=3) 0 => array (size=1) 'a' => string 'a' (length=1) 1 => array (size=1) 'b' => string 'b' (length=1) 2 => array (size=1) 'c' => string 'c' (length=1)</code>
After var_dump, I used array_push for the second array, but I hope the index is not in numbers, but directly in English,
as follows:
<code>array (size=3) 'a' => string '3' (length=1) 'b' => string '1' (length=1) 'c' => string '2' (length=1) </code>
is_numeric()
$arr1 = $arr2 = []; $arr = array('0'=>'3','1','2','a'=>'a','b'=>'b','c'=>'c'); foreach ($arr as $key=>$value) { if (is_numeric($key)) { $arr1[$key] = $value; } else { $arr2[$key] = $value; } }