Here is my example array
$inputs = array();
array(4) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["name"]=>
string(4) "13.1"
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["name"]=>
string(4) "13.2"
}
[2]=>
array(2) {
["id"]=>
string(1) "3"
["name"]=>
string(4) "14.1"
}
[3]=>
array(2) {
["id"]=>
string(1) "4"
["name"]=>
string(4) "14.2"
}
}
During my foreach loop, I could be currently working with $inputs[2]
and conditional logic would determine that immediately above this one a new array needs to be added. Please see next example..
array(4) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["name"]=>
string(4) "13.1"
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["name"]=>
string(4) "13.2"
}
[2]=>
array(2) {
["id"]=>
string(1) "NEW"
["name"]=>
string(4) "NEW"
}
[3]=>
array(2) {
["id"]=>
string(1) "3"
["name"]=>
string(4) "14.1"
}
[4]=>
array(2) {
["id"]=>
string(1) "4"
["name"]=>
string(4) "14.2"
}
}
How would I do this?
thanks for your help in advance