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