TAILIEUCHUNG - Học php, mysql và javascript - p 7

Figure 3-4. A multidimensional array simulated with matchboxes three more arrays, as in Example 3-5, in which the array is set up with a game already in progress. Example 3-5. Defining a two-dimensional array Once again, we’ve moved up a step in complexity, but it’s easy to understand if you grasp the basic array syntax. There are three array() constructs nested inside the outer array() construct. To then return the third element in the second row of this array, you would use the following PHP command, which will display an “x”: echo $oxo[1][2]; Remember that array indexes (pointers at elements within an array) start from. | Figure 3-4. A multidimensional array simulated with matchboxes three more arrays as in Example 3-5 in which the array is set up with a game already in progress. Example 3-5. Defining a two-dimensional array php oxo array array x o array o o x array x o Once again we ve moved up a step in complexity but it s easy to understand if you grasp the basic array syntax. There are three array constructs nested inside the outer array construct. To then return the third element in the second row of this array you would use the following PHP command which will display an x echo oxo 1 2 Remember that array indexes pointers at elements within an array start from zero not one so the 1 in the previous command refers to the second of the three arrays and the 2 references the third position within that array. It will return the contents of the matchbox three along and two down. As mentioned arrays with even more dimensions are supported by simply creating more arrays within arrays. However we will not be covering arrays of more than two dimensions in this book. The Structure of PHP 41 And don t worry if you re still having difficulty getting to grips with using arrays as the subject is explained in detail in Chapter 6. Variable naming rules When creating PHP variables you must follow these four rules Variable names must start with a letter of the alphabet or the _ underscore character. Variable names can contain only the characters a-z A-Z 0-9 and _ underscore . Variable names may not contain spaces. If a variable must comprise more than one word it should be separated with the _ underscore character. . user_name . Variable names are case-sensitive. The variable High_Score is not the same as the variable high_score. Operators Operators are the mathematical string comparison and logical commands such as plus minus times and divide. PHP looks a lot like plain arithmetic for instance the following statement outputs 8 echo 6 2 Before moving on to learn what PHP can do for you take a

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.