Đang chuẩn bị liên kết để tải về tài liệu:
Professional Information Technology-Programming Book part 68

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Tham khảo tài liệu 'professional information technology-programming book part 68', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Summary In this lesson you have learned how to work with strings in PHP. In the next lesson you will examine how regular expressions are used to perform pattern matching on strings. Lesson 7. Working with Arrays In this lesson you will learn how to use arrays in PHP to store and retrieve indexed data. What Is an Array An array is a variable type that can store and index a set of values. An array is useful when the data you want to store has something in common or is logically grouped into a set. Creating and Accessing Arrays Suppose you wanted to store the average temperature for each month of the year. Using single-value variablesalso known as scalar variablesyou would need 12 different variables temp_j an temp_feb and so onto store the values. By using an array you can use a single variable name to group the values together and let an index key indicate which month each value refers to. The following PHP statement declares an array called temps and assigns it 12 values that represent the temperatures for January through December temps array 38 40 49 60 70 79 84 83 76 65 54 42 The array temps that is created contains 12 values that are indexed with numeric key values from 0 to 11. To reference an indexed value from an array you suffix the variable name with the index key. To display March s temperature for example you would use the following echo temps 2 Index Numbers Because index values begin at zero by default the value for Marchthe third monthis contained in the second element of the array. The square brackets syntax can also be used to assign values to array elements. To set a new value for November for instance you could use the following temps 10 56 Thearray Function The array function is a shortcut function that quickly builds an array from a supplied list of values rather than adding each element in turn. If you omit the index number when assigning an array element the next highest index number will automatically be used. Starting with an empty array .

TÀI LIỆU 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.