Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2004, 11:12 AM
Authorized User
 
Join Date: Jun 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 73 - Array Syntax

Hello,

Not that it is particularly important but page 73 states this code :


<?php
$name = array("firstname"=>"Albert", "lastname"=>"Einstein", "age"="124");

echo $name["firstname"];

?>


All I get in response is this in the browser:


 Parse error: parse error, unexpected '=', expecting ')'


Also in reference to the operator => I can't find that mentioned anywhere.

Confused,

Carl

 
Old August 18th, 2004, 01:02 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

$name = array("firstname"=>"Albert", "lastname"=>"Einstein", "age"=>"124");
You left out a right angle bracket.

The '=>' is a special operator used to associate array indices with their value. It's only used in two places, in the array and foreach constructs.

foreach ($array as $key => $value)
{
   // foreach is used to walk through an array
   // it can create variables for each key and value
   // of each indice.
}

http://www.php.net/array
http://www.php.net/foreach

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old August 18th, 2004, 01:23 PM
Authorized User
 
Join Date: Jun 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot !

Thats how it was written in the book though, although it's not actually part of the main excercises.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Posting String Array From one page to another page Samatha ASP.NET 1.0 and 1.1 Professional 1 December 6th, 2006 03:54 AM
Beginning Dreamweaver MX 2004 - Page 73 ColinS Dreamweaver (all versions) 4 May 14th, 2005 02:01 AM
session level array syntax requested lcsgeek Classic ASP Professional 4 January 27th, 2004 06:47 AM
Chap 5 capitals.ph (array syntax) growch BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 6 October 31st, 2003 12:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.