function get($a,$b,$c) {
$y = explode($b,$a);
$x = explode($c,$y[1]);
return $x[0];
}
返回错误
注意:未定义offset: 1 in
$y[1]
未设置
在运行它之前,你需要检查是否有一个值。
$y = explode( $b, $a );
if ( isset( $y[1] ) ) {
$x = explode( $c, $y[1] );
return ( isset( $x[0] ) ) ? $x[0] : '';
} else {
return '';
}
这是一个警告,表示数组键没有设置。
你可以使用php的相关函数,无论一个特定的数组键是否存在。
http://php.net/manual/en/function.array-key-exists.php