I have this array that I’m printing with this function in php: print_r($curriculos);
Array ( [0] => SofLa\SoflaBundle\Entity\Curriculittle Object
( [id:SofLa\SoflaBundle\Entity\Curriculittle:private] => 51
[nombrecompleto:SofLa\SoflaBundle\Entity\Curriculittle:private] => Bobo
[direccion:SofLa\SoflaBundle\Entity\Curriculittle:private] => Miami
[estado:SofLa\SoflaBundle\Entity\Curriculittle:private] => Lauderdale
[ciudad:SofLa\SoflaBundle\Entity\Curriculittle:private] => Key West
[telefono:SofLa\SoflaBundle\Entity\Curriculittle:private] => 3
...
[1] => SofLa\SoflaBundle\Entity\Curriculittle Object
( [id:SofLa\SoflaBundle\Entity\Curriculittle:private] => 52
[nombrecompleto:SofLa\SoflaBundle\Entity\Curriculittle:private] => Hola
[direccion:SofLa\SoflaBundle\Entity\Curriculittle:private] => Ricardo
[estado:SofLa\SoflaBundle\Entity\Curriculittle:private] => hola
[ciudad:SofLa\SoflaBundle\Entity\Curriculittle:private] => Manare
[telefono:SofLa\SoflaBundle\Entity\Curriculittle:private] => 25
...
What I want to do is to access this array in the controller of my application, of course i have $curriculos variable in the controller.
The thing is when I try to access data like this:
$curriculos[0]["id:SofLa\SoflaBundle\Entity\Curriculittle:private"];
it says Cannot use object of type SofLa\SoflaBundle\Entity\Curriculittle as array in C:\wamp\www\sym\src\SofLa\SoflaBundle\Controller\DefaultController.php.
I’ve been trying others solutions like accessing the data like this $curriculos->edad. But it says Trying to get property of non-object.
Any ideas? 🙂
Well, it seems you have an array of objects, right? So it should be:
However, entities in Doctrine2 should NEVER have public fields (proxies won’t work), so you should add a method to encapsulate retrieval of the field, something along the lines of:
Sorry for mixing english and spanish… I don’t know any spanish at all, so I don’t know if you use any equivalents of get/set when writing programs.