Jump to content

dcjones

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    warwickshire, United Kingdom

dcjones's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi all, I am working with some data in a CVS file. The content following the following format: AEDBuy=6.4452&AEDSell=5.1002&ANGBuy=3.164&ANGSell=2.298&ARSBuy=6.8626&ARSSell=5.3583 So far I have managed to replave the & sign with a comma to make it a truve CVS but I am now trying to extract the data into an array which I can manipulate and feed it into a SQL tabel. I have also remove the = sign. $file_handle = fopen("DATA/lgwrates.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); if($line_of_text $line_of_text = str_replace("&", ",", $line_of_text); $line_of_text = str_replace("=", "", $line_of_text); $parts = explode(',', $line_of_text); foreach( $parts as $key=> $value){ $rate = $value; $country = substr($rate,1,3); $sellRate = substr($rate,6); The issue I have is how can I read the data from the file so that I end up with: AEDBuy6.4452AEDSell=5.1002,ANGBuy3.164ANGSell=2.298,ARSBuy6.8626ARSSell=5.3583 and so on. I may be going about this completely wrong so if someone could point me in the right direction that would be great. Many thanks in advance. Dereck
  2. Hi all I have a script which produces random codes used for coupons. The script that generates the random code is: function generate_coupons(){ global $db, $t, $vars; $vars['discount'] = trim("$vars[discount_v] $vars[discount_t]"); set_date_from_smarty('begin_date', $vars); set_date_from_smarty('expire_date', $vars); $batch_id = $db->generate_coupons($vars); $coupons = $db->get_coupons('batch_id', $batch_id); $t->assign('coupons', $coupons); $t->display('coupon_generated_tier.php'); } On my SMARTY template script I have: input type="text" readonly="readonly" class="agentformbl" name="couponid" value="{foreach from=$coupons item=c} {$c.code} {/foreach}" size="32" /> What I am trying to do is assign the content of "{foreach from=$coupons item=c}{$c.code}{/foreach} to a $_SESSION variable. Hers a very bad example: $_SESSION['c'] = {foreach from=$coupons item=c}{$c.code}{/foreach} I know that thos example is not the way it is done, but I just don't know how. Can anyone please help. Best regards dereck
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.