PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $cities = [ [ "id" => 3, "name" => "HRK", "city" => "KHARKIV" ], [ "id" => 6, "name" => "KHE", "city" => "KHERSON" ], [ "id" => 7, "name" => "LVO", "city" => "LVOV" ], [ "id" => 4, "name" => "ODS", "city" => "ODESA" ] ]; $last_city = ''; foreach($cities as $city) { if ($last_city != '') { echo '<option value="'.$last_city.'-'.$city['name'].'">'.$last_city.'-'.$city['name'].'</option>'. PHP_EOL; } //echo '<option value="'.$city['name'].'">'.$city['name'].'</option>' . PHP_EOL; vprintf('<option value="%">%</option>',[$city['name']]); $last_city = $city['name']; }
Show:  
Copy Clear