<?php
$itinerary = array (array('portName'=>'Day At Sea'), array('portName'=>'Moscow'));
$badPorts = array('At Sea', 'Day At Sea', 'Cruising The Mediterranean Sea');
$image = '';
$index = 0;
$image .= implode(',', array_reduce($itinerary, function ($result, $item) use ($badPorts, &$index){
if(!in_array($item['portName'], $badPorts)) $result[$index] = $item['portName'];
$index++;
return $result;
}, array()));
var_dump($image);
$image2 = '';
array_walk($itinerary, function($item, $index) use(&$image2, $badPorts){
if(!in_array($item['portName'], $badPorts)) $image2 += $index.":".$item['portName'];
+});
var_dump($image2);
- Output for 5.3.23, 5.4.13
- Parse error: syntax error, unexpected '}' in /in/dT725 on line 17
Process exited with code 255. - Output for 5.3.0 - 5.3.22, 5.4.0 - 5.4.12
- Parse error: syntax error, unexpected '}' in pGXq8 on line 17
Process exited with code 255.
preferences:
180.54 ms | 1395 KiB | 45 Q