I wish to add key/value pairs into the same index of an array inside a loop.
Something Like this:
$attributes = array();
for($i=0;$i<3;$i++)
{
array_push($attributes, array("title" => "this is content" . $i));
}
except that the above would add new arrays to the original one. The output of above would be:
[{"title":"this is content0"},{"title":"this is content1"},{"title":"this is content2"}]
What I need is something like the following:
{"title1":"Hello World!","title2":"yoyoyyooyy"}
So the array still has a single index but multiple key/value pairs in that index separated by a comma.
Please HELP!!!