Matt:
This worked perfect. Thank you. I didn't realize it was reassigning, I
thought it would work similar to array_push and add to the existing data. I
get it now, thanks to you.

Thanks again. I had been so frustrated I was losing my objectivity. 


Christopher J. Crane 
Network Manager - Infrastructure Services 
IKON Document Efficiency at Work 



-----Original Message-----
From: Matt Matijevich [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 02, 2004 12:25 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Str_Replace Command

<snip>
  $StockURL =
"http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,danky&f=sl1&e=.txt";;
  $StockResults = implode('', file("$StockURL"));
  $Rows = split("\n", $StockResults);
  foreach($Rows as $Row) {
    list($Symbol, $Price) = split(",", $Row);  $Symbol = str_replace('"',
"", $Symbol);
    echo $Symbol." - ".$Price."<br>\n";
    $TickerData = array ($Symbol => $Price);
    }
  print_r($TickerData);
</snip>

why not replace:
$TickerData = array ($Symbol => $Price);

that line reassigns $TickerData to a array with one element in it everytime
you call it.  The last time through your loop, $Symbol = ''
and $Price = '', so you get Array ( [] => ) when you print_r

with this:
$TickerData[$Symbol] = $Price;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to