skip to Main Content

foreach array_combine two array by php

There are two arrays that One is the correct answers and the other is the user's answer. My Php: $i=1; $correct = array('a','d','c','a','b','c'); $user = array('a','c','c','a','c','c'); foreach (array_combine($correct, $user) as $co => $ur) { if($co == $ur) { echo $i.':true…

VIEW QUESTION

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
Back To Top
Search