Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
多么好的格式啊!我想我仍然不明白,但无论如何我都会尝试回答...
explode
尝试做如果您遇到问题,请使用您想出的代码编辑您的问题。
What a nice format! I think I still don't get it, but I'll try answering anyway...
Try to do this and if you're having trouble, edit your question with the code you'd come up with.
没有真正理解你的琴弦是如何工作的;这段代码应该可以完成这项工作。
$timetables = explode("\n", $source); foreach($timetables as $tablekey => $days) { $timetables[$tablekey] = explode('Q', $days); foreach($timetables[$tablekey] as $daykey => $hours) $timetables[$tablekey][$daykey] = explode(' ', $hours) } print_r($timetables, true);
Without really understanding how your strings work; This code should do the job.
$x = //... $x = explode("\n", $x); foreach($x as $k => $v) { $x[$k] = explode("Q", $x[$k]); foreach($x[$k] as $kk => $vv) { $x[$k][$kk] = explode(" ", $x[$k][$kk]); } }
使用 array_map 我想你会得到更好的代码。
With array_map I think you wiil get somewhat nicer code.
这是一个采用分隔符数组的递归函数:
function multi_explode($delimiters, $val) { $delimiter = array_shift($delimiters); if (!empty($delimiter)) { $val = explode($delimiter, $val); foreach($val as $key => $valval) { $val[$key] = multi_explode($delimiters, $valval); } } return $val; }
Here is a recursive function that takes an array of delimiters:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(4)
多么好的格式啊!我想我仍然不明白,但无论如何我都会尝试回答...
explode
和“\n”,您将获得该数组中每个元素 ,将其替换为带有 'Q' 的explode
本身,您将获得一个二维数组,explode
中,将该元素替换为explode
> 本身带有 ' '尝试做如果您遇到问题,请使用您想出的代码编辑您的问题。
What a nice format! I think I still don't get it, but I'll try answering anyway...
explode
with "\n" and you'll get an array of timetablesexplode
of itself with 'Q' and you'll have a 2-dimensional arrayexplode
of itself with ' 'Try to do this and if you're having trouble, edit your question with the code you'd come up with.
没有真正理解你的琴弦是如何工作的;这段代码应该可以完成这项工作。
Without really understanding how your strings work; This code should do the job.
使用 array_map 我想你会得到更好的代码。
With array_map I think you wiil get somewhat nicer code.
这是一个采用分隔符数组的递归函数:
Here is a recursive function that takes an array of delimiters: