String to Array help

What am I doing wrong here?


<?
  $Genres = "Acoustic, Alternative, Jazz, Latin";
  $MyGenres = array($Genres);
  if (in_array("Acoustic", $MyGenres)) {
      echo "Got Acoustic";
  }else{
      echo"Got nothing";
  }
?>

[OUTPUT] > Got nothing

You are checking for an array that does not exist. Feel free to RTFM on how to construct a proper array.

http://php.net/manual/en/language.types.array.php

Well, you created a string, not an array. Very close to it…

Try $MyGenres = array(“Acoustic, Alternative, Jazz, Latin”);

Sponsor our Newsletter | Privacy Policy | Terms of Service