troubleshooting Question

Why is this while loop or function in general not working?

Avatar of Mark Brady
Mark BradyFlag for United States of America asked on
31 Comments3 Solutions1929 ViewsLast Modified:
function miniDays($start){ // Function to return array of table header names with day of the week
if($start != ""){
      $days_of_the_week = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
      $key = array_search($start,$days_of_the_week);
            if($key == 7) {$key = 0;}
            $day.$x = $days_of_the_week[$key];
            $key ++;
return array($day1,$day2,$day3,$day4,$day5,$day6,$day7);

I am trying to return an array of short weekday names. When I feed 'Wed' into the above function, I need to get back an array like this;

$week_days = miniDays['Wed']; // Should have an array of weekday names now starting with "Wed"

The above array should start like this:  "Wed", "Thu", "Fri', "Sat", "Sun", "Mon", "Tue"

But it returns nothing. Can you see any typo in my function or any mistake that is obvious? Basically you feed the function a short week name and the array returned should list all the days in the week starting with the day you fed into it.

Thanks in advance.
Join our community to see this answer!
Unlock 3 Answers and 31 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 31 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros