Forum Moderators: coopster
$str="info1|info2|info3"; $fields=explode("|",$str); echo explode("|",$str)[0]; Now, I often only need the first field, to do so, I use this code:
echo explode("|",$str)[0];
$str="info1|info2|info3";
// true - return string before first occurrence of "|" (exclusive)
$firstField = strstr($str,'|',true);