Hi guys, I’ve been trying to find out what’s causing this problem, but all my searches are taking me in circles so I thought I’d just post and ask straight up. I think it’s a conflict between my PHP script and EE somewhere, but since I’m a total PHP newbie, I’m a bit in over my head as to figuring this one out.
Here’s the jist… I have a feed I’m importing that looks something like this:
2012-11-08;;1;;0,2012-11-09;;1;;0,2012-11-10;;1;;0,2012-11-13;;2;;0,etc, etcNothing too complex, pretty basic. Using PHP I’m trying to break the feed down to where I can grab just the string items that have a “2” in them after the date. But my PHP script is throwing this errors back out:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 2
Filename: libraries/Functions.php(680) : eval()‘d code
Line Number: 14
Here’s my script below… something’s not right with it I’m sure, but like I said, I’m still learning the basics here. I really could use some help in getting this working within EE. FWIW I know it’s the if($date[2] == 2) line that’s causing the problem. I wrote another script for this task that was giving me a similar errors, so I’m sure it’s something to do with the conditionals in EE.
<?php
$myFile = file_get_contents('http://url_to_my_file_here/');
$element = explode(",", $myFile);
$array = array();
foreach($element as $row){
array_push($array, explode(";", $row));
}
foreach($array as $date){
$newdate = new DateTime($date[0]);
$newdate = $newdate->format('m-d-Y');
//echo $newdate;
if($date[2] == 2)
echo '"'.$newdate.'",';
}
?>Any tips or ideas would be most appreciated.
Thanks,
- John