2

This is my code:

if(is_array($ItemAttr["Actor"])){
  $Actors = implode(", ", $ItemAttr["Actor"]);
} else {
  $Actors = $ItemAttr["Actor"];
}

I'm getting undefined index: Actor in **line 1** and **line 3**

I guess i should use isset() function. Can anyone tell me how to combine that function with is_array() function..?

1 Answer 1

8

Not sure if this is what you mean but:

if( isset($ItemAttr["Actor"]) && is_array($ItemAttr["Actor"])){
    ....
}

In this case you are checking if the index exist before accessing its value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.