Summary: Given an array
{a, b, ..., w, x, ..., z}
insert several elements {m, n, ..., r} in the position of x, also removing x. Final array:
{a, b, ..., w, m, n, ..., r, ..., z}
Have an return array
$return_arr = array(
'saa'=>'A2223',
'asab'=>'asB',
'wqed'=>'D234',
'wqasee'=>'Esd',
'wqewf'=>'Ffds',
'monwa'=>'monwaaas'//*
);
it will return new array if in this array exist this element ‘monwa’=>’monwaaas’.And the new array will be the next order of element that we found
for example
if we have $return_arr =>the new_array should be
(add two more element ('hi'=>'HI','hello'=>'HELLO')
$new_array = array(
'saa'=>'A2223',
'asab'=>'asB',
'wqed'=>'D234',
'wqasee'=>'Esd',
'wqewf'=>'Ffds',
'hi'=>'HI',
'hello'=>'HELLO'
);
And if
$return_arr = array(
'saa'=>'A2223',
'asab'=>'asB',
'monwa'=>'monwaaas',//*
'wqed'=>'D234',
'wqasee'=>'Esd',
'wqewf'=>'Ffds'
);
the new_array should be:
$new_array = array(
'saa'=>'A2223',
'asab'=>'asB',
'hi'=>'HI',
'hello'=>'HELLO',
'wqed'=>'D234',
'wqasee'=>'Esd',
'wqewf'=>'Ffds'
);
And so On…
Anybody knows how to do this?
thanks
Example on an online interpreter.
1) Search the position of that element, 2) remove the element and 3) then insert in its previous position.
With these functions: