ainoy31 Posted February 1, 2008 Share Posted February 1, 2008 Hello- I need help determine why this code is not working. Seems like my logic is correct. So, I have two arrays: #1 - Array ( [0] => Array ( [0] => Del Date/Time:01/31/08 ) [1] => Array ( [0] => Del Date/Time ) [2] => Array ( [0] => 01/31/08 ) ) #2 - Array ( [0] => Array ( [0] => Cur Status:Delivered ) [1] => Array ( [0] => Delivered ) ) Here is my code that I need help with: if(stristr($line, 'Del Date/Time:')) { $pat = '#(Del Date/Time):.*?(\d{2}/\d{2}/\d{2})#is'; preg_match_all($pat, $line, $matches); $deliv_date = date("Y-m-d", strtotime( $matches[2][0] ) ); $delivered = true; }//end of if(stristr($line, 'Del Date/Time:')) if(stristr($line, 'Cur Status:')) { $pat = '~Cur Status:\</td\><td class="text" width=\'90\' bgcolor=\'#f5f5dc\'\>((??!\</td\>).)+)\</td\>~s'; preg_match_all($pat, $line, $matches); $status = $matches[1][0]; if($status != 'Delivered') { $deliv_date = null; $delivered = false; } } return array($delivered, false, $status, $deliv_date); The problem is that if status does not equal 'Delivered', then it should not set the $deliv_date to null and $delivered to false. However, in my case it does and overwrites the previous $deliv_date value. Right, if $status does not equal 'Delivered', then $deliv_date = null; and $delivered = false; should not be executed? I hope this is pretty clear. Maybe I am overlooking something simply here. Much appreciation. Link to comment https://forums.phpfreaks.com/topic/88961-second-eye/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.