php - Echoing Complex Array in Structured Manner -


$hours = [   'mon' => ['07:30 am' => '04:00 pm'],   'tue' => ['07:30 am' => '04:00 pm'],   'wed' => ['07:30 am' => '04:00 pm'],   'thu' => ['07:30 am' => '04:00 pm'],   'fri' => ['07:30 am' => '04:00 pm'],   'sat' => ['10:00 am' => '04:00 pm'],   'sun' => ['closed'] ]; 

i'm having trouble echoing out above array structured as:

mon - 7:30 - 4:00 pm

tue - 7:30 - 4:00 pm

...

in type of structured way either in table or within divs structure using css.

this code may you, echos array in table

$hours = [   'mon' => ['07:30 am' => '04:00 pm'],   'tue' => ['07:30 am' => '04:00 pm'],   'wed' => ['07:30 am' => '04:00 pm'],   'thu' => ['07:30 am' => '04:00 pm'],   'fri' => ['07:30 am' => '04:00 pm'],   'sat' => ['10:00 am' => '04:00 pm'],   'sun' => ['closed'] ];   echo "<table>"; foreach($hours $key => $value) {    echo "<tr>";    echo "<td>" . $key . "</td>";    foreach($value $key2 => $value2)    {        echo "<td>" . (($key2!=0)?$key2:'') . "</td>";        echo "<td>" . $value2 . "</td>";    }    echo "</tr>"; } echo "</table>"; 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -