$start = 6;$list = [ '1楼', '2楼', '3楼', '4楼', '5楼',];
How to add a value to a key in an array when traversing $start
Since it is now the Ajax load comment, the floor in the HTML code passed to the front end is from 1-5
I think the second time I asked for it, the number of floors is 6, 7, 8, 9, 10
The two functions on the label can only be referenced to the value, not to the key. So there's no other way to handle this. In the foreach case of no use.
PS: I now think of the use of array_keys all the keys out of the processing, and in the original array to merge
Reply content:
$start = 6;$list = [ '1楼', '2楼', '3楼', '4楼', '5楼',];
How to add a value to a key in an array when traversing $start
Since it is now the Ajax load comment, the floor in the HTML code passed to the front end is from 1-5
I think the second time I asked for it, the number of floors is 6, 7, 8, 9, 10
The two functions on the label can only be referenced to the value, not to the key. So there's no other way to handle this. In the foreach case of no use.
PS: I now think of the use of array_keys all the keys out of the processing, and in the original array to merge
$list = array_flip( array_map(function($key) use ($start) { return $start + (int)$key; }, array_flip($list)) );
Https://3v4l.org/O8rXf
$key_list = range($start, $start + count($list) - 1);$list = array_combine($key_list, $list);