how can i get the first and last word of element in array php -
i trying first , last word of element in array, i've tried code didn't proper result
foreach(unserialize($q['qlite']) $qkey => ql) { foreach($ql zp) { $response = $zp[0]; echo '$response'; } }
and result got array( [0] => michael jordan best player of time [23] => 23 )
what want first value "michael" , last value "time"
foreach($ql $zp) { $response = $zp[0]; $words = explode(' ', $zp[0]); echo $words[0]; echo $words[count($words) - 1]; }
as explained in comment, need split string each word , return first , last of array created split.
Comments
Post a Comment