PHP:从数组检查和读取[重复]

This question already has an answer here:

I have an array like :-

$arr = array(
    "Sci-Fi",
    "Action"
);

How can check if Action exists in this array , And how can convert it to (Sci-Fi,Action)

Thankx

</div>

In your question $arr is the array. First we'll check if 'Action' is in the array.

    if(in_array('Action',$arr)){
      //in_array checks if 'Action' is in the array
      echo "Action is in the array!";
    }

Now we need to "implode" the array to turn it into a string.

    echo "(" . implode(',', $arr) . ")";
    //implode glues the parts of your array together into a string using the supplied "glue", in this case a comma.

php.net has it all documented, but I know it's hard to just know what a function name is, especially something cryptic like implode. When you're learning it's nice to get a friendly answer.