"array combine three or more arrays with php" Answer’s

0

Personally for readability I would do it this way:

$keys   = array('u1','u2','u3');
$names  = array('Bob','Fred','Joe');
$emails = array('bob@mail.com','fred@mail.com','joe@mail.com');
$ids    = array(1,2,3);
$result = array();

foreach ($keys as $id => $key) {
    $result[$key] = array(
        'name'  => $names[$id],
        'email' => $emails[$id],
        'id'    => $ids[$id],
    );
}
Wednesday, March 31, 2021
 
zIs
answered 10 Months ago
zIs
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :