i have a string this one: position1, position2
Basically i want to have this kind of structure -
array(
array('position' => 'position 1'),
array('position' => 'position 2')
)
i have tried this so far.
$positions = explode(',', "position1, position2");
$modPoses = [];
foreach($positions as $pose):
$modPoses['position'] = $pose;
endforeach;
print_r($modPoses);
Output:
Array ( [position] => position2 )
How can i get desired(mentioned above) array structure? Thank you.
['position'=>'position1', 'position'=>'position2']<-- this doesn't make any sense$array['position']to return?[{position:position1},{'position:position2}]is it posible using php and convert it into Js