I've been creating a php script for a project and have been running it on my development server which is running PHP 5.4.17
I need to move it over to my production server which is running PHP 5.4.19
When using the array_map
function on my development server I got the results I needed with no problem.
On my production server I get the parse error:
Parse error: syntax error, unexpected '[' in /path/to/script/ on line 219
My code used was:
$arr = array_map(
function($results_titles, $results_image, $results_summary, $results_dates, $results_links) {
return ['title' => $results_titles, 'image' => $results_image, 'summary' => $results_summary, 'date' => $results_dates, 'link' => $results_links];
},
$results_titles, $results_image, $results_summary, $results_dates, $results_links
);
array(...)
, not[...]
– hindmost Feb 18 '14 at 8:15[array_elements]
was valid, maybe the problem is there, try using the classic structure:return array('title => $result_titles, etc...);
I would keep using that syntax for a while, just in case xD – aleation Feb 18 '14 at 8:16[]
directly for the arrays too. OP, I think you are on a version prior to 5.4.0, check this link, your code should be valid on >5.4 php.net/manual/en/migration54.new-features.php – aleation Feb 18 '14 at 8:20