0
之间我与数据载列的阵列如下PHP分裂阵列在值
[0] =>"npage:new",
[1] =>"data:data",
[2] =>"data:data",
[3] =>"npage:new",
[4] =>"data:data",
[5] =>"data:data",
[6] =>"data:data",
[7] =>"npage:new",
[8] =>"data:data",
[9] =>"data:data",
进出口试图重新排列阵列,使得在每个“NPAGE:新的”它为它创建的数据的另一索引和下一个“npage:new”。直到最后一组没有“npage:new”但仍然需要索引。 例子:
[0] =>
"data:data",
"data:data",
[1] =>
"data:data",
"data:data",
"data:data",
[2] =>
"data:data",
"data:data",
我有以下,但它返回一个空数组&我想我是在复杂的事情。
$source[] = the array
$destination = array();
$startval = "new";
$found = 0;
$starindex = 0;
foreach ($source as $index => $value){
if ($value === $startval) {
$found = $value;
$startindex = $index;
}
elseif ($value === $found) {
$destination[] = array_slice($source, $startindex, $index - $startindex + 1);
$found = 0;
}
}
感谢!这并获得成功。 – brad