|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bravo - very helpful !
It's great to see an article that gives me a half-dozen things I can use immediately - great examples, too ! Thanks for one of the best things I've read on DevShed.
|
|
#2
|
|||
|
|||
|
Nice, but no stack?
In 'push and pull', you do give the functions, array_pop, array_push etc, but you don't give where there really handy for:
stacks. For the rest, good article, but I knew them all already. |
|
#3
|
|||
|
|||
|
Foreach
I'd like to also mention the 'foreach()' function, which proves incredibly handy when sorting through and applying operations on individual key/value pairs. Much more user friendly than 'array_walk()'. For more info check out "PHP.net's foreach() page":http://www.php.net/manual/en/control-structures.foreach.php
|
|
#4
|
|||
|
|||
|
gosh
Hello,
Excellent article that emphasises what I've been thinking for a while - if you want to do something in PHP, don't do it the convoluted manner you have to do in C or VB, there's bound to be a function to do it in PHP! A couple of things though: 1. It would have been nice to see some multi-dimensional array stuff 2. It would have been nice to see array integration with mySQL 3. Arrays have tens of functions, as does most other areas of PHP, which is why halve of the PHP language is missed out by most people (probably more by me!). What is needed is PHP to evolve into a more object oriented language and, in the case of arrays, create have an array (and all other constructs, like databases, sessions, etc) as classes with all the functions as members. Neil |
|
#5
|
|||
|
|||
|
Hoo-array
An excellant intro & advanced guide to php arrays !
|
|
#6
|
|||
|
|||
|
Very Nice!
That was a very informative article, I especially liked the sort functions.
Hope to see more articles this in the future! |
|
#7
|
|||
|
|||
|
Excellent article!
Excellent article! Well written, easy to read, and very useful info! :)
|
|
#8
|
|||
|
|||
|
range()
Support for character sequences and decrementing arrays will not be available until version 4.1 <br>
(ie. $alphabet = range("a", "z"); ) The same goes for range(<i>high</i>, <i>low</i>). |
|
#9
|
|||
|
|||
|
referencing arrays with curlies "{ }"
One can reference a hash/associative array using curly brackets. It removes the hassle of having to escape single quote marks used as apostrophes or to concatenate the string with an array.
For example: $requests = array( "Lion" => "courage", "Scarecrow" => "brain", "Tin Man" => "heart", "Dorothy" => "home"); echo "The Wizard of Oz agreed to grant the Tin Man a {$requests["Tin Man"]}."; echo "The lion's request was to gain {$requests['Lion']}."; |
|
#10
|
|||
|
|||
|
Good Job!
The functions you covered in this article will be very helpful to me. The book from which I learned PHP gave me a good, workable knowledge of the language, but didn't go into this much detail with arrays. Thanks for the added insight!!
|
|
#11
|
|||
|
|||
|
"" is not null
In the example for array pad() the second comment says that $students = array_pad($students, 4 ""); will return an array containing 4 <i>null</i> values.
Instead, it will return an array containg 4 EMPTY values which is not the same thing. $students = array();<br> $students = array_pad($students, 4, "");<br> echo isset($students[0])? "isset TRUE<br>" : "isset FALSE";<br> echo empty($students[0])? "empty TRUE<br>" : "empty FALSE";<br> echo is_null($students[0])? "isnull TRUE " : "isnull FALSE";<br> what makes it confusing is that PHP returns true when comparing an empty string with NULL: $a = ""; $b = NULL; echo $a == $b ? "true" : "false"; /* yes it does return TRUE because $a is converted to NULL in the process of equality comparison */ echo $a === $b ? "true" : "false"; /* but $a is not identical to NULL, that is why the identity comparison returns FALSE */ echo is_null($a) ? "true" : "false"; // returns FALSE<br> echo is_null($b) ? "true" : "false"; // returns TRUE |
|
#12
|
|||
|
|||
|
dsa
how are u?
|
|
#13
|
|||
|
|||
|
Mega Thanks!
Mega Thanks to you! I have been working with php for 3 months trying to get some code out. I didn't have time to play with all thoes functions! They have DRAMATICALLY increased efficiency in my code!! You are a God send for writhing this article! This article was written very clearly and easy to follow!!
Thanks, Ariel |
|
#14
|
|||
|
|||
|
Very Comprehensive
Didn't realise how many options you had with PHP to enable array manipulation.
Thanks heaps |
|
#15
|
|||
|
|||
|
Great
This was just what I was looking for, keep up the good work
---------------------- http://www.webhostgold.com |
![]() |
| Viewing: Dev Shed Forums > Other > Development Articles > Array Manipulation With PHP4 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|