如果我有以下格式的数组,如何将这些数组值的一部分分配给新数组?(数值123
并654
表示可以在这些位置分隔数组)
$fruits = array();
$vehicles = array();
$all_words = array ("123", "apple", ”orange”, ………, ”bannana”, ”123”, ”654”, ”car”, ”bus”, ………, ”train”, ”bike”, ”654”);
//continuous ……… Indicate there can be unknown amount of array elements.
//Also, these numeric values of 123 and 645 can be changed to something convenient
我可以看到使用$fruits = array_slice($array, 1, 5)
我可以将这个数组的一部分放入一个新数组中。但是,如果我不知道两个数字之间的数组长度(123
和654
),我如何将这些值分配给一个新数组?