Im going through a PHP tutorial and about halfway through it starts using \n all over the place without any explanation - What does this do?
Google didnt help as it justs searches for the n lol
Thanks!
Printable View
Im going through a PHP tutorial and about halfway through it starts using \n all over the place without any explanation - What does this do?
Google didnt help as it justs searches for the n lol
Thanks!
"\n" is a unix escape code meaning "new line"
see also: \t for tab, \\ for backslash, and so on
Ok - i think i under stand that - however i have come up with another problem:
I have been given code to make a table - as far as i can tell its the same as i am copying from but it will not work
Can anyone see the problem?Code:<html>
<head>
<title>Table Example</title>
</head>
<body>
<table border=1 bgcolor=yellow>
<?php
$AcmeCars = array ("Ford", "Dodge", "Chevy");
$AcmeCarId = array ("K234", "J987", "F982");
for ($×=0; $× < count ($AcmeCars); $×++) {
print "<tr><td>$AcmeCarId[$×]</td>";
print"<td>$Acme Cars[$×]</td></tr>\n";
}
?>
</table>
</body>
</html>
Thanks
Works fine for me though, $Acme Cars needs to be $AcmeCars on the last print line.
Doesn't 'count' need to be changed to '$count', then initialised?
As far as I can tell, you're saying "keep looping round this code until $X is not less than count". Assuming I've understood it correctly, count must be a number. Therefore, above the loops, put:
$count = 5;
then in the loop, change 'count' to '$count'.
That should then go through the loop 5 times.
What error is PHP throwing at you anyway?
um... no, count is a php method to count the number of elemts in an array. see http://uk2.php.net/countQuote:
Originally Posted by ajbrun
Oh right - I didn't know that. Thanks :).
Ah, what i was doing was opening it through my ftp program which was not opening it through the server - which i didnt realise!! Its working now thanks.