What is the best way to accomplish the following.
I have lines in this format:
$s1 = "name1|type1"; //(pipe is the separator) $s2 = "name2|type2"; $s3 = "name3"; //(in some of them type can be missing)
Suppose nameN / typeN are strings and they cannot contain a pipe.
Since I need an exctract name / type separetly , I do:
$temp = explode('|', $s1); $name = $temp[0]; $type = ( isset($temp[1]) ? $temp[1] : '' );
Is there an easier (smarter, faster) way to do this without doing isset($temp[1]) or count($temp) .
Thanks!
php explode
Marco demaio
source share