I'm facing a dilemma here... I have an array structured like this:
[{'city':'LA','store':'Bobs Burgers'},{'city':'LA','store':'Burger King'},{'city':'Sacramento','store':'Jimmy Burger'}]
While iterating through these burger joints in a table, I need to insert a row whenever the city changes. How can I achieve this?
In PHP, the solution would look something like this:
<?php
foreach ($store in $burgerplaces){
if ($store['city']!=$prev_city){
# display header for the city
}
#print store info
$prev_city=$store['city'];
}
?>