Reputation: 21
Why wont this work?
Trying to learn php.
Posted from iphone notepad => codepad.
EDIT:
Updates: • removed spaces • replaced html line breaks w/ \n's as per codepad • added code to recognize new makes • seperated makes & models--it looks better
Next step is to implement a table.
Sorry for not posting code directly friends
Upvotes: 0
Views: 56
Reputation: 59699
In your raw code, you have garbage characters that are messing up PHP's parse of the code:
<?php
$cars = array(
  array(
  "make" => "toyota",
  "model" => "corolla",
  "size" => "compact"
  ),
I just downloaded your raw code from the paste, and opened it with a simple text editor. Somebody else can feel free to open it with a more advanced editor to say what garbage characters are actually there but not being displayed in the codepad output. But this is why codepad is reporting an error on line 3.
Upvotes: 3
Reputation: 4614
The error is that you have =
in some places where you need =>
. Lines 34 and 35
"make" = "nissan",
"model" = "maxima",
Should be like:
"make" => "nissan",
"model" => "maxima",
This is the real message that I got:
PHP Parse error: syntax error, unexpected '=', expecting ')' in php shell code on line 33
Also, when you're referring to string indexes, you need to use quotes to identify a string literal, so this:
$cars[$i][make]
Should be this:
$cars[$i]['make']
This is only a warning, but it is a good one to avoid :-)
Upvotes: 2