未定义的偏移通知消息

Undefined offset notice messages

您好,我遇到了未定义的偏移通知消息。我已经分解了数组,然后我正在获取数组元素5。请指导我解决这个问题。

注意:未定义的偏移量:5

function test() {       
$path_val=request_path();    
$exploded_val=explode("/",$path_val);    
if(isset($exploded_val)){
$entity_id=$exploded_val[5];
}}

试试这个

if(!empty($exploded_val[5])){//doAction}