0 Комментарии
0 Поделились
3Кб Просмотры
0 предпросмотр
Каталог
Знакомьтесь и заводите новых друзей
-
Войдите, чтобы отмечать, делиться и комментировать!
-
PHP ArraysAn array stores multiple values in one single variable: ExampleGet your own PHP Server $cars = array("Volvo", "BMW", "Toyota"); Try it Yourself » What is an Array? An array is a special variable that can hold many values under a single name, and you can access the values by referring to an index number or name. PHP Array Types In PHP, there are three types of arrays:...0 Комментарии 0 Поделились 4Кб Просмотры 0 предпросмотр
-
PHP Indexed ArraysPHP Indexed Arrays In indexed arrays each item has an index number. By default, the first item has index 0, the second item has item 1, etc. ExampleGet your own PHP Server Create and display an indexed array: $cars = array("Volvo", "BMW", "Toyota"); var_dump($cars); Try it Yourself » Access Indexed Arrays To access an array item you can refer to the index number. Example...0 Комментарии 0 Поделились 4Кб Просмотры 0 предпросмотр
-
PHP Associative ArraysPHP Associative Arrays Associative arrays are arrays that use named keys that you assign to them. ExampleGet your own PHP Server $car = array("brand"=>"Ford", "model"=>"Mustang", "year"=>1964); var_dump($car); Try it Yourself » Access Associative Arrays To access an array item you can refer to the key name. Example Display the model of the car: $car =...0 Комментарии 0 Поделились 6Кб Просмотры 0 предпросмотр
-
PHP Create ArraysCreate Array You can create arrays by using the array() function: ExampleGet your own PHP Server $cars = array("Volvo", "BMW", "Toyota"); Try it Yourself » You can also use a shorter syntax by using the [] brackets: Example $cars = ["Volvo", "BMW", "Toyota"]; Try it Yourself » Multiple Lines Line breaks are not important, so an array...0 Комментарии 0 Поделились 5Кб Просмотры 0 предпросмотр
-
PHP Access ArraysAccess Array Item To access an array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. ExampleGet your own PHP Server Access an item by referring to its index number: $cars = array("Volvo", "BMW", "Toyota"); echo $cars[2]; Try it Yourself » Note: The first item has index 0. To access items from an associative...0 Комментарии 0 Поделились 6Кб Просмотры 0 предпросмотр
-
PHP Update Array ItemsUpdate Array Item To update an existing array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. ExampleGet your own PHP Server Change the second array item from "BMW" to "Ford": $cars = array("Volvo", "BMW", "Toyota"); $cars[1] = "Ford"; Try it Yourself » Note: The first item has index 0. To update items from...0 Комментарии 0 Поделились 5Кб Просмотры 0 предпросмотр
-
PHP Add Array ItemsAdd Array Item To add items to an existing array, you can use the bracket [] syntax. ExampleGet your own PHP Server Add one more item to the fruits array: $fruits = array("Apple", "Banana", "Cherry"); $fruits[] = "Orange"; Try it Yourself » Associative Arrays To add items to an associative array, or key/value array, use brackets [] for the key,...0 Комментарии 0 Поделились 5Кб Просмотры 0 предпросмотр
-
PHP Delete Array ItemsRemove Array Item To remove an existing item from an array, you can use the array_splice() function. With the array_splice() function you specify the index (where to start) and how many items you want to delete. ExampleGet your own PHP Server Remove the second item: $cars = array("Volvo", "BMW", "Toyota"); array_splice($cars, 1, 1); Try it Yourself » After...0 Комментарии 0 Поделились 5Кб Просмотры 0 предпросмотр
-
PHP Sorting ArraysThe elements in an array can be sorted in alphabetical or numerical order, descending or ascending. PHP - Sort Functions For Arrays In this chapter, we will go through the following PHP array sort functions: sort() - sort arrays in ascending order rsort() - sort arrays in descending order asort() - sort associative arrays in ascending order, according to the value...0 Комментарии 0 Поделились 6Кб Просмотры 0 предпросмотр