I am loading from a .data file and each line has all of the variables divided by "|". The code I use is in Perl and I need to have access to these variables just the same as with my perl code but with PHP. Please let me know if you have any idea what I can do. Thanks in advance. Here is the code.
$data_file="ads .data";
open(DAT, $data_file) || die("Could not open file!");
@raw_data=<DAT> ;
close(DAT);
foreach $ads (@raw_data)
{
chop($ads);
($ad_number,$us er_name,$user_t ype,$date,$var_ 1,$var_2,$var_3 ,$var_4,$var_5, $var_6,$var_7,$ name,$var_8,$ci ty,$province,$p ostal_code,$cou ntry,$phone_num ber,$var_9,$ema il,$var_10,$cat egory,$subcateg ory,$caption_he ader,$caption,$ ad_text,$price, $var_11,$var_12 ,$var_13,$var_1 4,$var_15,$var_ 16,$private,$va r_17)=split(/\|/,$ads);
if ($city eq "Toronto") {
print "<table width=100%><tr> <td>
$city
</td></tr></table>";
}
}
$data_file="ads .data";
open(DAT, $data_file) || die("Could not open file!");
@raw_data=<DAT> ;
close(DAT);
foreach $ads (@raw_data)
{
chop($ads);
($ad_number,$us er_name,$user_t ype,$date,$var_ 1,$var_2,$var_3 ,$var_4,$var_5, $var_6,$var_7,$ name,$var_8,$ci ty,$province,$p ostal_code,$cou ntry,$phone_num ber,$var_9,$ema il,$var_10,$cat egory,$subcateg ory,$caption_he ader,$caption,$ ad_text,$price, $var_11,$var_12 ,$var_13,$var_1 4,$var_15,$var_ 16,$private,$va r_17)=split(/\|/,$ads);
if ($city eq "Toronto") {
print "<table width=100%><tr> <td>
$city
</td></tr></table>";
}
}
Comment