1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Issue with numbers in PHP

Discussion in 'PHP' started by nickharper, Dec 16, 2010.

  1. #1
    Hi,

    I have the following code:

    <?php
    	//foreach($prices as $key=>$val) 
    	for($i=0; $i<=1000; $i=$i+100)
    	{
    		$ss = substr(strval($i),0,1);
    		$ss = $ss.",100";
    		$p = number_format($i,2,".",",");
    		$vv = "£".($i)."-£".($i+100);
    		$jj = str_replace(",","%2C",$ss);
    ?>		
    		<option value="<?php echo $ss?>" <?php if(isset($_REQUEST['price']) && $_REQUEST['price']==$ss) echo "selected='selected'";?>><?php echo $vv;?></option>	
    <?php
    	}
    ?>
    PHP:
    The issue I have is that $vv seems to be £100 more than $ss.

    If I select £400 - £500 from the drop down, the value it uses is £300 - £400.

    Can anybody help?

    Thanks
     
    nickharper, Dec 16, 2010 IP