I have a array
["item1","item2","item3"]
I want to get an array of ["1","2","3"]
how to get that in php
I have a array
["item1","item2","item3"]
I want to get an array of ["1","2","3"]
how to get that in php
1) Simply use
$res = str_replace('item', '', $array);
Output $res
Array
(
[0] => 1
[1] => 2
[2] => 3
)
2) Using array_map()
$array = array_map(
function($str) {
return str_replace('item', '', $str);
},
$array
);