我有这个数组(摘要)
array (size=631)
0 => string '11:27:35.750 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
' (length=80)
1 => string '11:27:35.751 INFO - Launching a standalone Selenium Server
' (length=60)
2 => string '2018-07-17 11:27:35.785:INFO::main: Logging initialized @534ms to org.seleniumhq.jetty9.util.log.StdErrLog
' (length=108)
3 => string '11:27:35.890 INFO - Driver class not found: com.opera.core.systems.OperaDriver
' (length=80)
4 => string '11:27:35.891 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
' (length=97)
5 => string 'Unable to create new instances on this machine.
' (length=49)
6 => string '11:27:35.891 INFO - Driver class not found: com.opera.core.systems.OperaDriver
' (length=80)
7 => string '11:27:35.891 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
' (length=90)
8 => string '11:27:35.893 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
' (length=102)
9 => string ' registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
' (length=130)
10 => string '2018-07-17 11:27:35.966:INFO:osjs.Server:main: jetty-9.4.3.v20170317
是否有一个内置函数按其索引对数组进行排序,以使索引pos 0的内容为10,反之亦然?
还是我必须自己写?
答案 0 :(得分:1)
您似乎正在寻找array_reverse
<?php
$input = array("php", 4.0, array("green", "red"));
$reversed = array_reverse($input);
$preserved = array_reverse($input, true);
print_r($input);
print_r($reversed);
print_r($preserved);
?>
输出:
Array
(
[0] => php
[1] => 4
[2] => Array
(
[0] => green
[1] => red
)
)
Array
(
[0] => Array
(
[0] => green
[1] => red
)
[1] => 4
[2] => php
)
Array
(
[2] => Array
(
[0] => green
[1] => red
)
[1] => 4
[0] => php
)
答案 1 :(得分:0)
好的,我找到了解决方案。我必须使用功能array_reverse