im made a news programs and i wanted to convert the mysql to the regular format. so i found a code that would work and it gives me a parse error. heres that code:
well i believe they belong on there. the rest of my code has that and it works fine. ill give it a try though also ill give the explode() a try too thx.
// For this test, assign a string value of yyyy/mm/dd .
$row['Date'] = '2003/03/22';
// From your code.
list($year,$month,$day)= split('[/.-]', {$row['Date']});
$newdate =date("m-j-Y", mktime(0, 0, 0, $month, $day, $year));
// For this test, echo it.
echo $newdate;
?>
The following gives me this error, which I guess is more or less the same as yours:
Code:
Parse error: parse error, unexpected '{' in e:\web\foo\test.php on line 7
This means that "{" on line 7 is not supposed to be there.
But without "{" and "}", like this:
PHP Code:
<?php
// For this test, assign a string value of yyyy/mm/dd .
$row['Date'] = '2003/03/22';
// From your code, without "{" and "}" around $row['Date']
list($year,$month,$day)= split('[/.-]', $row['Date']);
$newdate =date("m-j-Y", mktime(0, 0, 0, $month, $day, $year));
// For this test, echo it.
echo $newdate;
?>
I get this:
Code:
03-22-2003
I guess this is what you wanted. There shouldn't be any code block there. The rest of your code works with "{" and "}" around variables because you are using it to indicate "this is a variable" to PHP within double-quotations (i.e. string). You could, thus, double-quote it like so:
This would give you the same output as the one before, but unless you have to concatenate something else to your $row['Date'], all it does is add 4 more unnecessary characters to your code - it makes a bit harder to read the code, too.
i forgot to post that i gave your suggestion a test and it works now thx blaw, if you want i got another problem with it now,if you want to help me view the post i added yesterday