I want to make
<?php $str = "I want to access 2nd or 3rd index in one line"; echo explode(" ",$str)[2]; ?>
We can easily access the first index using
stristr($str," ",true);
or
$foo = array_shift(explode(':', $foo));
or
list($str) = explode(" ", $str);
BUT
HOW TO ACCESS A SPECIFIC INDEX [1], [2] OR [3] IN ONE LINE
source share