I don't understand how the display of an array work. When I print_r($context->correspondance) I get this :
Array ( [0] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 864 [vtarif] => 45 [vnbplace] => 1 [vheuredepart] => 12 [vcontraintes] => soyez GENTILS ) [1] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 817 [vtarif] => 4 [vnbplace] => 3 [vheuredepart] => 4 [vcontraintes] => no,n ) [2] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 762 [vtarif] => 31 [vnbplace] => 3 [vheuredepart] => 6 [vcontraintes] => chien autorise ) [3] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 846 [vtarif] => 862 [vnbplace] => 1 [vheuredepart] => 3 [vcontraintes] => tt ) [4] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 863 [vtarif] => 1 [vnbplace] => 1 [vheuredepart] => 1 [vcontraintes] => Moi, Nicolas Guégan, vous invite tous à mon anniversaire le 18/12/2022 au trampoline park d'Avignon pour s'amusert tous ensemble ! N'héitez pas à me contacter via mon adresse mail : [email protected] Je vous aime tous ! ) [5] => Array ( [vdepart] => Biarritz [vcorrespondance] => [vid] => 866 [vtarif] => 2 [vnbplace] => 3 [vheuredepart] => 10 [vcontraintes] => Salut ) )
But when I just want to display only one column by doing echo($context->correspondance->vdepart) or echo($context->correspondance[0]->vdepart[0]) I get this :
Trying to get property of non-object in file...
How can I display this ? Thank you in advance for your answers !
CodePudding user response:
$context is an object while its property corresponance is an array. You get the contents of vdepart this way:
print_r($context->correspondance[0]['vdepart']);
CodePudding user response:
Try this:
<?php
echo '<pre>';
print_r($context->correspondance[0]['vdepart']);
// or
var_dump($context->correspondance[0]['vdepart']);
echo '</pre>';
?>