|
PHP Working with arrays
|
|
12-22-2009, 11:01 AM
Post: #1
|
|||
|
|||
|
PHP Working with arrays
Hello!
Its me again! With yet another useful tutorial for php. This time we will take a little look at the arrays in php. How to use, them, and not get scared! Lets start with the simplest example: Code: <?phpWell its pretty simple. First we create a new array with 2 values. Then we display the values in the browser. Each value in array has a key, array keys are optional, if not declared they are automatically incremental, starting from 0, meaning that if we do only: Code: $arr = array(1,2);So if we follow that logic if we do: Code: $arr = array(1,2); In the first example we created a so called associative array. Meaning that we put a "known" name to each key, for the respective value. This way is preferred for us if we describe stuff, like objects, items, etc. And the auto incremental keys are preferred when we have multiple arrays that we like to be in a array (i know it sounds complicated but bare with me). So an example is needed to clarify things ![]() Code: $arr = array(array('name' => 'john', 'age' => 20), array('name' => 'bruce', 'age' => '15')); Each item on the list has several properties, in our case the properties are name and age.Again this is a very basic usage case. Arrays are very powerful, they can represent basically any set of items, objects, persons and so on. Mastering them is very important for knowing your way around in solving php problems
|
|||
|
12-22-2009, 12:01 PM
Post: #2
|
|||
|
|||
|
RE: PHP Working with arrays
Good tutorial, +reped!
Have a nice day. Please check the Announcements and News section of the forum, there are great events and important news waiting for you. Please register and check the site regularly for updates. Please bookmark us! Thank-you very much! |
|||
|
01-09-2010, 03:11 AM
Post: #3
|
|||
|
|||
|
RE: PHP Working with arrays
Nice Tut
|
|||
|
04-12-2010, 04:45 AM
Post: #4
|
|||
|
|||
|
RE: PHP Working with arrays
With PHP, we only have arrays. They are very simple. It is something like a list of items, where each entry has two properties: A key and a value. If you have the key, you can access a value directly - otherwise, you will have too look for it. PHP allows us unlimited dimensions of arrays, which means that we can have an array that has a range of arrays, which have a range of arrays, and so on.
Defeat is not bitter unless you swallow it. |
|||
|
08-04-2011, 10:21 AM
Post: #5
|
|||
|
|||
|
RE: PHP Working with arrays
Yeah Nice Tut Ill Try.
|
|||
|
08-15-2011, 03:03 PM
Post: #6
|
|||
|
|||
|
RE: PHP Working with arrays
Perfect TUTorial
|
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)







In the first example we created a so called associative array. Meaning that we put a "known" name to each key, for the respective value. 


