Repeat challenge to the PHP function



  • Why can a relapse of the function cause a mistake?

    function getCurrentShowArr($slug) {
        require_once('some_api.php');
        $allShows = SomeApi::get("/catalog/theaters/networks/kinocentr/shows/all-long.phps")['shows']['show'];
        function showId($arr, $sl) {
            $i=0;
            do 
            $arr[$i]['alias'] == $sl ? $res = $arr[$i]['id']: '';
            while(++$i<count($arr));
            return $res;
        };
        $id = showId($allShows, $slug);
        $data = SomeApi::get("/catalog/theaters/networks/kinocentr/shows/{$id}.phps");
        $show = $data['show'];
        return $show;
    }
    

    $film1 = getCurrentShowArr('star-wars-7');
    $film2 = getCurrentShowArr('terminator');

    Erroneous report:

    [06-Jan-2016 16:58:01 UTC] PHP Fatal error: Cannot redeclare showId() (previously declared in home/domen/public_html/site/wp-content/themes/themename/functions.php:126) in home/domen/public_html/site/wp-content/themes/themep



  • Problem is, you define the function. showId each challenge getCurrentShowArr

    trivial solution -- define showId above.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2