How can you easily avoid getting this error/notice:
Notice: Undefined offset: 1 in /var/www/page.php on line 149
... in this code:
You get an undefined offset
when the thing you're trying to explode the string by ($value
) doesn't actually have it in, I believe.
This question is very much similar to this: undefined offset when using php explode(), where there is a much further explanation which should fully solve your issue.
As for checking for the occurrence of '|' as to prevent the error, you can do:
$pos = strpos($value,'|');
if(!($pos === false)) {
//$value does contain at least one |
}
Hope this helps.