Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 访问str_split()返回的数组会引发未定义的偏移量错误_Php_Arrays_Mysqli_Split - Fatal编程技术网

Php 访问str_split()返回的数组会引发未定义的偏移量错误

Php 访问str_split()返回的数组会引发未定义的偏移量错误,php,arrays,mysqli,split,Php,Arrays,Mysqli,Split,我需要将字符串12345拆分为一个字符数组。使用以下代码,我得到: 未定义偏移误差 否则,我将使用print\r()函数对整个数组进行回显 $arr = str_split('12345'); echo $arr[1]; 编辑: 完整代码: $id = 4; $sql = "SELECT * FROM `time_table` WHERE user_info_iduser_info = $id OR tutor_detail_idtutor_detail = $id"; $result =

我需要将字符串
12345
拆分为一个字符数组。使用以下代码,我得到:

未定义偏移误差

否则,我将使用
print\r()
函数对整个数组进行回显

$arr = str_split('12345');
echo $arr[1];
编辑:

完整代码:

$id  = 4;
$sql = "SELECT * FROM `time_table` WHERE user_info_iduser_info = $id OR tutor_detail_idtutor_detail = $id";
$result = mysqli_query($conn,$sql);// 5 rows selected

 while($row = mysqli_fetch_row($result)){
     echo $row[3];  // outputs 12345
     $arr = str_split($row[3]);
     echo $arr[1]; // should output 2 but not working :(
}

使用以下代码,而不是
str\u split

$str="12345";
$str_len = strlen( $str );
$arr = array();
for ( $i = 0; $i < $str_len; $i++ )
{
    $arr[] = $str[$i];
    echo "<br>".$str[$i]."<br>";
}
print_r( $arr );
$str=“12345”;
$str_len=strlen($str);
$arr=array();
对于($i=0;$i<$str_len;$i++)
{
$arr[]=$str[$i];
回声“
”$str[$i]。“
”; } 印刷费($arr);
请向我们展示您的真实完整代码-将字符串转换为arrayworks for me:complete code added@Rizier123也适用于me@newUser