Hi Guys,
when i take a date (i.e $startDate) and try to printit before the function myRecordHandler($record) the date appears corectly (the format is 20071112052015). When i try to print it inside the function myRecordHandler($record) it cannot be appeard. I am desperate for your help.
this an example of my code ...
<?php
$time = time()+$SETTINGS['timecorrection']*3600;
$startDate = date("YmdHis",$time);
print $startDate;
require("MagicParser.php");
function myRecordHandler($record)
{
$title = $record["product"];
$descr = $record["description"];
$image = $record["imageurl"];
$price = $record["price"];
print $startDate;
}
MagicParser_parse("name_of_file.csv","myRecordHandler","csv|124|1|0");
?>
Thank you in advance
Paschalis
Hi Paschalis,
You need to declare $startDate as global within myRecordHandler. The following should work:
<?php
$time = time()+$SETTINGS['timecorrection']*3600;
$startDate = date("YmdHis",$time);
print $startDate;
require("MagicParser.php");
function myRecordHandler($record)
{
global $startDate;
$title = $record["product"];
$descr = $record["description"];
$image = $record["imageurl"];
$price = $record["price"];
print $startDate;
}
MagicParser_parse("http://www.e-shop.gr/sql/feed/products_desc_rest.csv","myRecordHandler","csv|124|1|0");
?>
Cheers,
David.