skip to Main Content

PHP Merge child of an array into parent as independent

array( array( 'drive'=>array('test1'), 'wheel_drive'=>array('2WD','4WD') ), array( 0=>array( 'drive'=>array('test21','test31'), 'wheel_drive'=>array('2WD','4WD') ), 1=>array( 'drive'=>array('test32'), 'wheel_drive' => array('4WD') ) ), array( 'drive' => array('test4'), 'wheel_drive'=> array('2WD','4WD') ) ); Output: array( array('drive'=>array('test1'),'wheel_drive'=>array('2WD','4WD')), array('drive'=>array('test21','test31'),'wheel_drive'=>array('2WD','4WD')), array('drive'=> array('test32'),'wheel_drive' => array('4WD')), array('drive' => array('test4'),'wheel_drive'=> array('2WD','4WD')) ); How can…

VIEW QUESTION

properly assign records into correct parent using foreach php

I have a similar arrays like below: $agents = [ (object)["id"=> 301,"name"=> "Agent 1"], (object)["id"=> 303,"name"=> "Agent 2"], (object)["id"=> 301,"name"=> "Agent 3"], (object)["id"=> 305,"name"=> "Agent 4"], (object)["id"=> 306,"name"=> "Agent 5"], (object)["id"=> 303,"name"=> "Agent 6"] ]; $locations = [ (object)["xid"=> 148,"location_name"=>…

VIEW QUESTION
Back To Top
Search