$test = array (
"test1" => array("a" => "1", "b" => "2", "c" => "3")
);
I have an array like above. ı want to push its values in a loop. How can it be possible ? Could you please tell me ?
add comment (requires an account with 50 reputation) |
You didn't have specified to which you want to push your values.
the array will contain only "1", "2", "3". If you want a different output, please reply which output you want. |
|||
|
You can use
Function Reference: http://php.net/manual/en/function.array-push.php |
|||
|
Just use foreach!
|
|||||||
|
If you have to push new values you can just do like this:
or
|
|||||||
|
You can use foreach.
If you are expecting the first subarray to be only one as your example you can skip the first loop:
Edit: If you want to push data inside you can't use the local variables as $key and $value. You can use $key to reffer the original array variable. For example:
|
|||||
|
$test['test1'][$newKey] = $newValue;
? – dev-null-dweller 2 days ago