要實現將字符串倒序拆分為數組,可以使用以下方法:
$str = "Hello World"; $reverseArray = array_reverse(explode(' ', $str)); print_r($reverseArray);
這段代碼首先使用explode()函數將字符串按照空格進行拆分為數組,然后使用array_reverse()函數將數組進行倒序排列。最后使用print_r()函數打印出倒序排列后的數組。
explode()
array_reverse()
print_r()