Hướng dẫn dùng array reverse trong PHP
Hàm Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức. Cú phápCú pháp: Trong đó:
Ví dụCode $array = array( "php", "js", "css", "html" ); $reversed = array_reverse($array); $preserved = array_reverse($array, true); echo ""; print_r($array); echo ""; echo ""; print_r($reversed); echo ""; echo ""; print_r($preserved); echo ""; Kết quả Array ( [0] => php [1] => js [2] => css [3] => html ) Array ( [0] => html [1] => css [2] => js [3] => php ) Array ( [3] => html [2] => css [1] => js [0] => php ) Tham khảo:php.net Bài viết này được đăng tại [free tuts .net] Hàm Cú phápCú pháp: Trong đó:
Ví dụCode $array = array( "php", "js", "css", "html" ); $reversed = array_reverse($array); $preserved = array_reverse($array, true); echo ""; print_r($array); echo ""; echo ""; print_r($reversed); echo ""; echo ""; print_r($preserved); echo ""; Kết quả Array ( [0] => php [1] => js [2] => css [3] => html ) Array ( [0] => html [1] => css [2] => js [3] => php ) Array ( [3] => html [2] => css [1] => js [0] => php ) Tham khảo:php.net
Hướng dẫn cách sử dụng hàm array_reverse() về mảng trong lập trình PHP Tác dụng của hàm array_reverse()The The following table summarizes the technical details of this function.
SyntaxThe basic syntax of the array_reverse(array, preserve); The following example shows the
ParametersThe
More ExamplesHere're some more examples showing how The following example shows how to reverse the order of array elements while preserving the keys.
Bài viết này đã giúp ích cho bạn?Bài viết mới |