-1
Good morning,
I have a multidimensional array, shown below:
array(3) {
[0]=>
array(1) {
[0]=>
object(stdClass)#35 (3) {
["id"]=>
string(2) "73"
["valor"]=>
string(6) "200.00"
["compra_nome"]=>
string(8) "Chaveiro"
}
}
[1]=>
array(3) {
[0]=>
object(stdClass)#36 (3) {
["id"]=>
string(2) "74"
["valor"]=>
string(6) "500.00"
["compra_nome"]=>
string(17) "Pulseira"
}
[1]=>
object(stdClass)#37 (3) {
["id"]=>
string(2) "74"
["valor"]=>
string(6) "200.00"
["compra_nome"]=>
string(14) "Chave de Fenda"
}
[2]=>
object(stdClass)#38 (3) {
["id"]=>
string(2) "74"
["valor"]=>
string(6) "100.00"
["compra_nome"]=>
string(15) "Chuveiro"
}
}
[2]=>
array(1) {
[0]=>
object(stdClass)#39 (3) {
["id"]=>
string(2) "75"
["valor"]=>
string(6) "100.00"
["compra_nome"]=>
string(14) "Lampada"
}
}
}
I need to store in an array the values that the id, so I would need to do a foreach to mount a table with the values, so it should look like this:
My PHP code:
$clientes = $this->Oportunidades_model->buscaClientesComCondicoes($data);
$clientes_array = array();
foreach ($clientes as $key => $value) {
// var_dump($value->codigo_cli);
$clientes_array[] = $this->Oportunidades->buscaCompras($value->codigo_cli,$data);
}
PS: The variable that brings the multidimensional array at the beginning of the question is $clientes_array No ideas ;/
I’m using PHP with Codeigniter but can be pure php too..
Edit: is returning with its code:
It would need to return 3 tables and join the 73.74.75 records in 3 different tables equal to the image above;
Thank you for your Vinicius respostsas! I put an Edit in the post showing how it is getting. Are 3 different ids and 6 tables. I would need it to be 3 tables with the respective ids, and the records that are of the same ID would be in the same table. In other words, table id 74(has 3 records) ai in this table will have the 3 records of ID 74.
– Robert Landigo