|
-
Oct 19th, 2011, 05:52 AM
#1
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 19th, 2011, 06:45 AM
#2
Hyperactive Member
Re: What does "=>" do ?
isn't it a separator used in associative arrays? 
i find so, after google it.
i mean:
Code:
<?php
$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);
foreach($ages as $key=>$val)
{
echo $key;
}
?>
Last edited by Aash; Oct 19th, 2011 at 06:59 AM.
-
Oct 19th, 2011, 07:53 AM
#3
Re: What does "=>" do ?
Thanks 
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 19th, 2011, 09:03 AM
#4
Re: [RESOLVED] What does "=>" do ?
It's not specifically used for associative arrays, but simply for describing a key (or index) and value pair. It's also used in the foreach statement. Here are some examples:
PHP Code:
// Associative array representing one book: // In this case, the key represents a field of data, and the value represents the field's value $book = array( "author" => "Richard Dawkins", "title" => "The God Delusion", "isbn" => "0618680004", "year" => 2006 );
// Numeric array representing multiple books // In this case, the key represents a book ID, and the value represents the book $books = array( 0 => $book, );
// Foreach foreach($books as $index => $book){ echo "On book #{$index} in collection.\r\n"; echo "Book data:\r\n"; foreach($book as $key => $value){ echo "{$key}: {$value}\r\n"; } }
-
Oct 19th, 2011, 09:18 AM
#5
Re: [RESOLVED] What does "=>" do ?
Thanks
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|