skip to Main Content

How to put IF in array PHP using "=>"

How can i put "if" inside array in php? mean: return [ 'cars' => [ 'test' => $arrayTest, 'test1' => $arrayTest1, ], 'session' => [ 'sessionkey' => "$xyz", 'lastlogintime' => $sess, if ($xyzp->available > 0){ 'availablenow' => true; } else{…

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

Php – How Display Random json_decode foreach

I want to display randomly in json_decode foreach. These codes are for Laravel/php. my table: id url attr 1 post-1 [{"at1":"Attr-A1","at2":"Attr-A2",.....}] my array (attr): [{ "at1":"Attr-A1", "at2":"Attr-A2", "at3":"Attr-A3", "at4":"Attr-A4", }, { "at1":"Attr-B1", "at2":"Attr-B2", "at3":"Attr-B3", "at4":"Attr-B4", }, { "at1":"Attr-C1", "at2":"Attr-C2", "at3":"Attr-C3",…

VIEW QUESTION
Back To Top
Search