Solarpitch Posted August 8, 2008 Share Posted August 8, 2008 Hi, I have the following function that will return an array as it result. The array will contain a series of times. <?php $result = check_times(); foreach($result as $times) { $theTime = $times[0]; } ?> What I'm looking to do is check to see if there is a specific time in the array and do something. I've been trying this but it doesn't work.. <?php if($theTime == "8:00") { $msg = "Time Reserved"; $error = 1; } //I also tried... if(in_array("8:00", $theTime)) { $msg = "Time Reserved"; $error = 1; } ?> Link to comment https://forums.phpfreaks.com/topic/118780-solved-testing-values-from-an-array/ Share on other sites More sharing options...
Solarpitch Posted August 8, 2008 Author Share Posted August 8, 2008 I should mention that when I echo $theTime = $times[0]; I get ... 8:00, 7:30, 7:40, 6:20, 6:10 ... So I know there are values Link to comment https://forums.phpfreaks.com/topic/118780-solved-testing-values-from-an-array/#findComment-611575 Share on other sites More sharing options...
The Little Guy Posted August 8, 2008 Share Posted August 8, 2008 foreach($theTime as $time){ if($time == "8:00"){ $msg = "Time Reserved"; $error = 1; } } Link to comment https://forums.phpfreaks.com/topic/118780-solved-testing-values-from-an-array/#findComment-611586 Share on other sites More sharing options...
Solarpitch Posted August 8, 2008 Author Share Posted August 8, 2008 ... put it in the loop... I see . Thanks Link to comment https://forums.phpfreaks.com/topic/118780-solved-testing-values-from-an-array/#findComment-611590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.