currently I’m cleaning up some code which creates a lot of php warnings.
I’ve got the following code:
if(isset($info[1])) {
list($artist, $song) = explode(" - ", trim(strip_tags($info[1])));
$fullname = trim(strip_tags($info[1]));
}
So I only want to execute this block is the index 1 is set. But when executing the the script I still get “Notice: Undefined offset: 1 in ….” on this line.
So what would be the right way to check if there is a value at a specified index in my array?
EDIT:
I tried your solutions but it is still not working as I expect.
I’ve added some debug stuff which just increased my confusion:
I’ve added the following for testing:
echo "<pre>";
print_r($info);
echo "</pre>";
echo ".";
die();
and the result is:
Array
(
[0] =>
)
.
Played @
[1] => Song Title
Right now I don’t really know how to interprete the output… can you give me a hint!?
First, you might need to ensure that
$infoexists:But my guess is that there’s no ‘ – ‘ match in
$info[1]after you trim it, and it’s there that only one element is returned (and therefore,list()would complain that there’s no 1 index).