【发布时间】:2015-11-16 07:11:11
【问题描述】:
我需要将字符串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 :(
}
【问题讨论】:
-
Can't reproduce your error 请向我们展示您的真实和完整代码
-
str_split - 将字符串转换为数组
-
完整代码添加@Rizier123
-
对我也很好@newUser