I am trying to create an php array elements to be nested.
For example:
I have this array:
array(3) {
[0]=>
string(9) "Example 1"
[1]=>
string(9) "Example 2"
[2]=>
string(9) "Example 3"
}
and I want the output to be like
array(1) {
[0]=>
string(9) "Example 1"
array(1) {
[0]=>
string(9) "Example 2"
array(1) {
[0]=>
string(9) "Example 3"
}
I tried with foreach() but without success. Can someone help me?
Thanks.
0and1respectively or use some named keys? Also, when you say "output", do you actually want to transform the input array or just display it nested temporarily? Please confirm.