mOrloff
02-04-2010, 10:06 PM
I came across this code, and I'm wondering whether the {} (or lack there of) are optional?
Is this clip (a direct copy&paste)
$fp = fopen('records_all_fields_truncated.csv', 'r');
if (!fp)
$i=0;
while (($data = fgetcsv($fp, 1000, ",")) != FALSE)
{
$data00 = str_replace("'","",$data[1]);
$data11 = str_replace("'","",$data[2]);
$data33 = str_replace("'","",$data[4]);
$data55 = str_replace("'","",$data[6]);
...
equivalent to
$fp = fopen('records_all_fields_truncated.csv', 'r');
if (!fp)
{ // ## Curly-brace added here ##
$i=0;
while (($data = fgetcsv($fp, 1000, ",")) != FALSE)
{
$data00 = str_replace("'","",$data[1]);
$data11 = str_replace("'","",$data[2]);
...
} // ## Curly-brace added here ##
I thought it would need them if it went into multiple lines.
Yes? No? Maybe So?
~ Mo
Is this clip (a direct copy&paste)
$fp = fopen('records_all_fields_truncated.csv', 'r');
if (!fp)
$i=0;
while (($data = fgetcsv($fp, 1000, ",")) != FALSE)
{
$data00 = str_replace("'","",$data[1]);
$data11 = str_replace("'","",$data[2]);
$data33 = str_replace("'","",$data[4]);
$data55 = str_replace("'","",$data[6]);
...
equivalent to
$fp = fopen('records_all_fields_truncated.csv', 'r');
if (!fp)
{ // ## Curly-brace added here ##
$i=0;
while (($data = fgetcsv($fp, 1000, ",")) != FALSE)
{
$data00 = str_replace("'","",$data[1]);
$data11 = str_replace("'","",$data[2]);
...
} // ## Curly-brace added here ##
I thought it would need them if it went into multiple lines.
Yes? No? Maybe So?
~ Mo