I want to get value from an array like this..
Array
(
[0] => May 2019 1
[1] => May 2019 14
)
I need to get just 1 and 14 from this array Thanks in advance!
I want to get value from an array like this..
Array
(
[0] => May 2019 1
[1] => May 2019 14
)
I need to get just 1 and 14 from this array Thanks in advance!
try this
$arr = array('your array');
foreach($arr as $v)
{
$date = end(explode(' ',$v));
//do your stuff
}
Use array_map()
, array_pop()
and explode()
$dates = array_map(function ($v){
$v = explode(' ',$v); //<--- Explodes your array using a space
return array_pop($v); //<--- Grabs the last element and returns to your $dates array.
},$yourarray);
Try this ,
$myarray = array('Monday, 06. May 2019 1','Sunday, 19. May 2019 14');
foreach($myarray as $str){
$split = explode(" ", $str);
echo $split[count($split)-1].'</br>';
}
As said by @pc-shooter this has been answered loads already, a quick Google gives the answer too. how-to-get-single-value-from-php-array
echo $array[1].$array[14];