Hướng dẫn dùng js unshift trong PHP
Hàm Show Nội dung chính
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" ); array_unshift($array, "html", "css"); echo ""; print_r($array); echo ""; Kết quả Array ( [0] => html [1] => css [2] => php [3] => js ) Hai phần tử Bài viết này được đăng tại [free tuts .net] Tham khảo: php.net Định nghĩa hàm array_unshift() trong PHP__Hàm Cú pháp của hàm array_unshift() trong PHP là:
Tham số
Ví dụ minh họa cách sử dụng hàm array_unshift() trong PHP:
Lưu chương trình trên trong một file có tên là test.php trong htdocs, sau đó mở trình duyệt và gõ địa chỉ http://localhost:8080/test.php sẽ cho kết quả: Xem thêm Hàm trong php Hàm
Cú phápCú pháp: Trong đó:
Ví dụCode $array = array( "php", "js" ); array_unshift($array, "html", "css"); echo ""; print_r($array); echo ""; Kết quả Array ( [0] => html [1] => css [2] => php [3] => js ) Hai phần tử Tham khảo: php.net (PHP 4, PHP 5, PHP 7, PHP 8) array_unshift — Prepend one or more elements to the beginning of an array Descriptionarray_unshift(array
Parametersarray The input array. values The values to prepend. Return Values Returns the new number of elements in the Changelog
ExamplesExample #1 array_unshift() example
The above example will output: Array ( [0] => apple [1] => raspberry [2] => orange [3] => banana ) See Also
sergei at gmx dot net ¶ 14 years ago
Anonymous ¶ 10 years ago
daniel at smallboxcms dot com ¶ 7 years ago
Richard Akindele ¶ 6 years ago
amschroeder at gmail dot com ¶ 15 years ago
$i = 0; $i < count($recordMonths); $i++)
php at electricsurfer dot com ¶ 18 years ago
robert dot wills at fuzzbrain dot uklinux dot net ¶ 20 years ago
= array("f"=>"five", "s" =>"six", "t" => sahn at hmc dot edu ¶ 21 years ago
chris dot NoThxSpam dot given at hp dot com ¶ 19 years ago
John Brooking ¶ 16 years ago
lagroue ¶ 18 years ago
|