I have to push an associative array in a normal array (not to convert).
Example (NO CODE):
project = {}
element["title"] = "My title"
element["description"] = "My description"
is there a way to have this
echo $project->title;
//or
echo $project[0]["title"]
? I'v tried this, but server says: ERROR 500
$i = 0;
$projects = {};
foreach($projectsElements as $element) {
while($i <= $nRowsForProject) {
$idSection = $element->idSection;
if($idSection == 1) $elements["".$element->internalDescription.""] = $element->text;
else if($idSection == 2) $elements["".$element->internalDescription.""] = $element->text;
else if($idSection == 3) $elements["".$element->internalDescription.""] = $element->text;
$i++;
}
array_push($projects,$elements);
$i=0;
}
$projects []= $element;
? – Ruslan Osmanov Oct 12 at 11:59->
operator references a property inside an object, but that is not possible in a declarative manner. Also creating an object is not possible by a simple$projects = {};
as you attempt to, that is a syntax error (your error 500). Instead you typically have to implement a class of which you then can instantiate an object. – arkascha Oct 12 at 12:01