<?php
$data = Array
(
0 => Array
(
'id' => 671,
'title' => 'BIEND',
'img' => '',
'ville' => 'marseille'
)
1 => Array
(
'id' => 670,
'title' => 'BIENC',
'img' => '',
'ville' => 'avignon'
)
2 => Array
(
'id' => 669,
'title' => 'BIENB',
'img' => '',
'ville' => 'avignon'
)
);
$result = array_reduce($data, function(&$cur, $x)
{
$cur[$x['ville']] = isset($cur[$x['ville']])?$cur[$x['ville']]+1:1;
}, []);
var_dump($result);
- Output for 5.4.0 - 5.4.25
- Parse error: syntax error, unexpected '1' (T_LNUMBER), expecting ')' in /in/fm2AO on line 13
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_LNUMBER, expecting ')' in /in/fm2AO on line 13
Process exited with code 255.
preferences:
194.28 ms | 1395 KiB | 62 Q