Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2004, 11:12 AM
Authorized User
 
Join Date: Jun 2004
Location: Coventry, , United Kingdom.
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

Reply With Quote
  #2 (permalink)  
Old August 18th, 2004, 01:02 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
Reply With Quote
  #3 (permalink)  
Old August 18th, 2004, 01:23 PM
Authorized User
 
Join Date: Jun 2004
Location: Coventry, , United Kingdom.
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:37 PM.


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