SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2003
    Location
    Toronto, Ontario
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Complex elseif statment

    Hey guys,

    I have a variable and need to add something to the end of it every time the statement isn't true. Each time running it against a .csv file to see if it exists. Here's what I got so far...

    Code:
    <?php $stock = $_GET['stock'];?>
    				
    <?
    
    $use_curl = 0;
    $symbols = "{$stock}";
    
    $quote = array();
    $url = "http://finance.yahoo.com/d/quotes.csv?s=$symbols&f=sl1d1t1c1ohgvj1pp2wernb3b6aa5xm4&e=.csv";
    
    $fcontents = @file($url);
    
    foreach($fcontents as $line) {
      $info = split(",", $line);
      for($i = 0; $i < sizeof($info); $i ++) {
    	$info[$i] = trim(str_replace('"', "", $info[$i]));
      }
      $last = $info[1];
      
    ?>
    
    <?php if($last != 0){ 
    		echo $last;
    	} else {
    Else add .OB to the end of the string and run...

    Code:
    <?
    
    $use_curl = 0;
    $symbols = "{$stock}";
    
    $quote = array();
    $url = "http://finance.yahoo.com/d/quotes.csv?s=$symbols&f=sl1d1t1c1ohgvj1pp2wernb3b6aa5xm4&e=.csv";
    
    $fcontents = @file($url);
    
    foreach($fcontents as $line) {
      $info = split(",", $line);
      for($i = 0; $i < sizeof($info); $i ++) {
    	$info[$i] = trim(str_replace('"', "", $info[$i]));
      }
      $last = $info[1];
      
    ?>
    again, then if it fails remove .OB from the end of the string and add .TO to the end of it and run the script again.

    Can anybody help me figure out what the best way of going about this would be?

    Thanks,
    Mario
    $ Available For Hire
    Need a website designed or coded? Then feel free to contact me!

    PSP Backgrounds - PSPBG.net || Photoshop Brushes - PSBrushes.net

  2. #2
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must be particularly dense today, as I can't really figure out what you're doing.

    I feel like you tried to abstract your concept, but didn't abstract enough and as such didn't provide enough details to understand fully what you're doing, but that may be me.

    What exactly is the statement you're using to compare your variable to? And uh... what is the variable? I just see code that's reading something from a CSV file, but I don't know what that data is supposed to represent or what exactly you are comparing.
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •