iterate a multidimensional array php code example

Example 1: php foreach through multidimensional array

foreach ($rows as $row) {
    echo $row['id'];
    echo $row['firstname'];
    echo $row['lastname'];
}

Example 2: create multidimensional array php for loop

$result = array();
foreach($members as $member) {
    $result[] = array(
        'firstname' => $member['firstname'],
        'last_name' => $member['last_name'],
        'job' => $member['job'],
        'desc' => $member['desc'],
        'image_url' => $member['image_url']
    );
}

Tags:

Php Example