Get support from Xavier Media
It is currently Sun Dec 08, 2013 12:25 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: trouble with my code from ur code array
PostPosted: Tue Dec 02, 2008 2:07 pm 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Tue Dec 02, 2008 2:01 pm
Posts: 5
Points: 0
Code:
<?php

         
$meals = array("breakfast" => 'cereal',"lunch" => 'hot dogs',"dinner" => 'hamburgers'};   

echo $meals[2];
//echo $meals [lunch]. "";
//echo $meals [dinner]. "";

?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

</body>
</html>

i always get an error when i run this on wamp. is it a configuration problem or drmwvr problem?
here's my error
Parse error: syntax error, unexpected '}', expecting ')' in C:\wamp\www\DWC_Remote\arrays.php on line 5
can't figure it out??


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
 Post subject: Re: trouble with my code from ur code array
PostPosted: Tue Dec 02, 2008 4:26 pm 
Offline
XavierForum.com Admin
XavierForum.com Admin
Super VIP Member
Super VIP Member
User avatar

Joined: Tue Mar 15, 2005 4:37 pm
Posts: 1082
Location: Sweden
Points: 1500
You should replace the } in your array code with a ) instead that should work:
PHP Code:
<?php


$meals = array("breakfast" => 'cereal',"lunch" => 'hot dogs',"dinner" => 'hamburgers');

echo $meals[2];
//echo $meals [lunch]. "";
//echo $meals [dinner]. "";

?>

_________________
Xavier Media®
Join me at LinkedIn | Get your latest blog post in your signature you too


Report this post
Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: trouble with my code from ur code array
PostPosted: Tue Dec 02, 2008 5:27 pm 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Tue Dec 02, 2008 2:01 pm
Posts: 5
Points: 0
thank you it works now. i guess my "warranty" on my eyes is over.
i tried a little twist with the code and it doesn't work here's what i did:
Code:
<?php

         
$meals = array("breakfast" => 'oatmeal',"lunch" => 'hot dogs',"dinner" => 'hamburgers');   

print_r($meals);
?>

<?php
echo $meals['1'];
?>



this echo tag doesn't return anything. OHHH maybe i have to delete the closing php tag and opening for the second command.no just tried it and that didn't work. but if i put in breakfast the script returns a value "oatmeal" can't one use the key [1] etc. to return a value?
thanks for your help.


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
 Post subject: Re: trouble with my code from ur code array
PostPosted: Tue Dec 02, 2008 6:30 pm 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Tue Dec 02, 2008 2:01 pm
Posts: 5
Points: 0
alright i see from ur tutorial once u name ur keys u have to stick to that. can't replace a named key with a number value.

*******************Resolved**************************


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]