mercredi 6 mai 2020

PHP Array Improvement

Quick question, most likely for a veteran will be easy, or maybe im asking for too much.

i have this code for laravel in php, im not fan to do a foreach, is there a better way? i guess should be an existing function that replace my values of arr to the keys match on arr2, but i dont know

Its really important not to change the order.

$arr=  ['filters', 'repeat', 'via', 'type'];
$arr2= [
        'filters' => 'text1',
        'repeat' => 'text2',
        'via' => 'text3',
        'type' => 'text4',
    ];

foreach($arr as $k)
    $res[]=$arr2[$k];

return $res;


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire