I have an array as follows:
'Ato001_1981',
'Ato002_1980',
'Ato003_1982',
'Ato003_1983',
'Ato004_1982',
'Ato013_1981',
'Ato013_1982',
'Ato013_1988',
'Ato031_1982',
'Ato032_1979',
'Ato039_1988',
'Ato060_1987',
'Ato065_1988',
'Ato066_1988',
'Ato067_1988',
'Ato076_1987',
'Ato077_1988',
'Ato078_1988',
'Ato095_1987',
'Ato137_1987',
'Ato144_1987'
I would like to break each row of the array to get the name and year and then sort as in the text below:
Ano Tipo
1988 Ato078
1988 Ato077
1988 Ato067
1988 Ato066
1988 Ato065
1988 Ato039
1988 Ato013
1987 Ato144
1987 Ato137
1987 Ato095
1987 Ato076
1987 Ato060
1983 Ato003
1982 Ato031
1982 Ato013
1982 Ato004
1982 Ato003
1981 Ato013
1981 Ato001
1980 Ato002
1979 Ato032
I tried the code below, but without success:
$new = array();
foreach($texto as $item):
$valor = explode('_', $item);
$new['ano'] = $valor[1];
$new['tipo'] = $valor[0];
print_r($new);
endforeach;