I am using this code:
<?php
include_once('/simple_html_dom.php');
$dom = file_get_html("http://www.gsmarena.com/samsung_i9300_galaxy_s_iii-4238.php");
foreach ($dom->find('tr') as $node) {
if (is_a($node->children(0), 'simple_html_dom_node')) {
if ($node->children(0)->plaintext == "Protection") {
$plain = explode(',', $node->children(1)->plaintext);
if($plain[0] === null){echo 'Nu are';}
elseif($plain[0]!== null) {echo $plain[0];
if($plain[1] === null){echo 'Nu are';}
elseif($plain[1] !== null) {echo $plain[1];}
}
}
}
}
?>
All i want is if there exist $plain[x] or $plain[y] to shows me if not to display an custom text (in my case 'Nu are'). All is fine, code works good because $plain[1] not exist in present case, but I receive an error too.
Here is the result receved from code:
Corning Gorilla Glass 2
Notice: Undefined offset: 1 in E:\server\htdocs\preluare\1.php on line 10
Nu are
First is shows me offset 0, because exist and second offset not exist and shows me that error and after error is the correct custom text.
Correct result is Corning Gorilla Glass 2
Nu are