Jump to content

array_search and returning a variable


bruckerrlb

Recommended Posts

I'm trying to do an array search and return a variable.

 

The Variables I"m trying to test to see if exists are:

$day_start = $day."_start";
$day_end = $day;
$day_end .= "_end";

 

The values of these arrays are:

             


//These are results from a database, and the result is something like 2am or 4pm or something along those lines
$mon_start = $row['mon_start'];
				$mon_end = $row['mon_end'];


				$tue_start = $row['tue_start'];
				$tue_end = $row['tue_end'];
				  

				$wed_start = $row['wed_start'];
				$wed_end = $row['wed_end'];

				$thur_start = $row['thur_start'];
				$thur_end = $row['thur_end'];

				$fri_start = $row['fri_start'];
				$fri_end = $row['fri_end'];

				$sat_start = $row['sat_start'];
				$sat_end = $row['sat_end'];

				$sun_start = $row['sun_start'];
				$sun_end = $row['sun_end'];

 

I have my array set up as following

$complete_time = array("mon_start" => $mon_start, "mon_end" => $mon_end, "tue_start" => $tue_start, "tue_end" => $tue_end, "wed_start" => $wed_start, "wed_end" => $wed_end, "thur_start" => $thur_start, "thur_end" => $thur_end, "fri_start" => $fri_start, "fri_end" => $fri_end, "sat_start" => $sat_start, "sat_end" => $sat_end, "sun_start" => $sun_start, "sun_end" => $sun_end);

 

Then, I have a while statement, trying to find the variable

while($r = array_search($complete_time, $day_start)) {
		echo "<td>Found something</td><td>$complete_time</td><td>$day_start</td><br />R is $r";
	}

 

Nothing seems to be getting printed out, can anyone tell me what I'm doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/201018-array_search-and-returning-a-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.