I am using CakePHP 2 and need to populate two PHP fields with JSON variables from a loop.
How can it be done ?
The variables are the car manufacturer id and the model id.
I have the JSON variables in this format available at JSON Form data:
array_brand[0][id]:"4232"
array_model[0][model_id]:"3647"
array_brand[1][id]:"3436"
array_model[1][model_id]:"1623"
The loop:
<div id="divCars">
<?php
for($i = 0; $i <= $arrayCars; $i++)
{
include 'ajax_cars.ctp';
}
?>
</div>
And inside the loop at ajax_cars.ctp i would like to populate the two fields:
- Car manufacturer id ( will be : $dataCars[‘id’] )
- And model id (will be $dataCars[‘model_id’]):
How can i populate $dataCars[‘id’] and $dataCars[‘model_id’] PHP variables from the available JSON variables :
array_brand[0][id]:"4232"
array_model[0][model_id]:"3647"
echo $this->Html->rows(
array(
array(
$this->Html->link('Publish Cars', array(
'controller' => 'Cars',
'action' => 'publish',
base64_encode($dataCars['id'])
base64_encode($dataCars['model_id'])
)
)
)
),
);