TAILIEUCHUNG - Zend PHP Certification Study Guide- P6

Zend PHP Certification Study Guide- P6:Hãy thẳng thừng, Giả sử bạn đang thuê một ai đó để giám sát hệ thống và PHP của bạn có nó thu hẹp xuống để hai ứng cử viên. Một trong những ứng cử viên nói, "Oh yeah, tôi biết tất cả về PHP." Các ứng cử viên khác nói, "Oh yeah, tôi biết tất cả về PHP, tôi đã được thông qua kỳ thi chứng chỉ Zend." câu hỏi tiếp theo của bạn có thể sẽ là "Zend Chứng nhận là gì?" Và các ứng viên nói, "Một công ty chuyên về PHP,. | 84 Chapter 4 Arrays php a array a 10 20 30 40 b array a 20 20 30 40 array array_merge_recursive a b var_dump array This results in the following array array 7 a array 2 0 int 10 1 int 20 0 int 20 1 int 30 2 int 40 3 int 20 4 int 30 5 int 40 In this case a a and b a are combined together into the array a array. Intersection and Difference If you want to extract all the elements that are common to two or more arrays you can use the array_intersect php a array a 20 36 40 b array b 20 30 40 Serializing Arrays 85 array array_intersect a b var_dump array Here s the output array 2 a int 20 1 int 40 As you can see this function only checks whether the values are the same the keys are ignored although the key of the leftmost array is preserved . If you want to include them in the check you should use array_intersect_assoc instead php a array a 20 36 40 b array b 20 30 40 array array_intersect_assoc a b var_dump array In this case the result will be a one-element array because the two 20 values in a and b have different keys array 1 1 int 40 If you want to calculate the difference between two or more arrays that is elements that only appear in one of the arrays but not in any of the others you will need to use either array_diff or array_diff_assoc instead. Serializing Arrays Given their flexibility arrays are often used to store all sorts of information and it is handy to be able to save their contents at the end of a script and retrieve them later on. This is done through a process known as serialization in which the contents of an array are rendered in a format that can later be used to rebuild the array in memory. 86 Chapter 4 Arrays In PHP serialization is taken care of by two functions serialized renders the array in a format that can be safely saved to any container such as a database field or a file capable of handling textual content. unserialize takes a serialized input and rebuilds the array in memory. Using these two functions is very easy php a array a 20 36 40 .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.