I've a multidimensional array of some arrays, in which the first values are ordered and included in a specific range.
Example:
A1=[[0,a],[3,b],[5,c],[6,a],[9,c]]
in which A1[i][0]
are in range (0,10)
How can I obtain an array where, if the first value
(A1[i][0]
) isn't a value present in the first array, e.g.
A1[i][0]==2
I insert an array with that value in the right position, with a specified second value (example A)?
Example of output i want:
A1=[[0,a],[1,A],[2,A],[3,b],[4,A],[5,c],[6,a],[7,A],[8,A],[9,c]]
$
.$A1[$i]
isn't$i
, usearray_splice()
to insert the element[$i, 'A']
there.