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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -