-2

got some code like

foreach ($aArray as $oObject) {
      array_push($this->_aOtherArray,
             array(
                   'foo' => $oObject->foo->value,
                   'bar' => $oObject->bar->value
             )
      );
}

Where I fill an array with other arrays in the foreach. Which works pretty fine. Now I want the same with the "new" array syntaxe like

array_push($_aOtherArray, "'foo' => $oObject->foo->value", "'bar' => $oObject->bar->value");

or something similar.

Thank you very much!

broxyl
  • 37
  • 6

1 Answers1

0

Are you looking for this syntaxe ?

foreach ($aArray as $oObject) {
  $this->_aOtherArray[] = [
               'foo' => $oObject->foo->value,
               'bar' => $oObject->bar->value
  ];
}