OZONE Asylum
Forums
Server-Side Scripting - Oh my!
What does -> and => in PHP mean?
This page's ID:
31549
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Also, "=>" is definitely for arrays. Consider the following array: [code]$fruits = array("apple", "pear", "orange");[/code] That's an array of three fruits. You can refer to "orange" in this case as: [code]echo $fuits[2];[/code] (Point of reference: arrays start counting from 0, so 0 is "apple", 1 is "pear".) That's fine and dandy, but the "=>" operand comes into play if you want to step through, or assign keys that are other than the standard array counting scheme. Let's say you wanted to have an array that started counting at 5 instead of 0: [code]$fruits = array(5=>"apple", "pear", "orange'");[/code] Great, now 5 is "apple", 6 is "pear", and 7 is "orange". But what if you wanted to step through each piece of an array with keys that are set to the color of the fruit, and do something with it? That's where foreach() comes into play: [code]$fruits = array("red"=>"apple", "green"=>"pear", "orange"=>"orange"); foreach($fruits as $color=>$fruit) { echo "$fruit is $color\n"; }[/code] I hope this helps you understand what the => operand means :) -[url=http://blog.brokenhattrick.com]S[/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail