|
-
Jan 23rd, 2012, 06:37 AM
#1
Thread Starter
Hyperactive Member
explode undefined offset
I am getting an undefined offset when using an explode. Usually it works however on one instance it fails. It is the second explode here that is failing, because there was no instance of " v " in the first one:
Code:
$pieces = explode(" v ", strip_tags($matches[$gameKeys[$e]]));
echo $pieces[1]."<p>";
$findtime = explode(",", $pieces[1]);
print_r($findtime);
produces:
Tunisia, GpC, 19:00
Array ( [0] => Tunisia [1] => GpC [2] => 19:00 )
Notice: Undefined offset: 1 in C:\xampp\htdocs\load_data.php on line 82
Notice: Undefined offset: 1 in C:\xampp\htdocs\load_data.php on line 83
Array ( [0] => )
Crystal Palace, (agg 0-1), SF, L2, 19:45
Array ( [0] => Crystal Palace [1] => (agg 0-1) [2] => SF [3] => L2 [4] => 19:45 )
So it works on the one above and below, however one of them seems to have nothing in it, and therefore pops up an error. This won't always be the case, but sometimes this might occur. The data it is reading from shows this:
Morocco v Tunisia, GpC, 19:00
Qatar OFF Sweden, 13:00
Cardiff v Crystal Palace, (agg 0-1), SF, L2, 19:45
So you can see the Qatar one is of slightly different format - it says OFF instead of " v ". Can i run an if statement on the first one. So if there was a " v " then do the next else have something that will avoid the error occuring?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|