Re: Str_Replace Command

From: Date: Mon, 02 Feb 2004 17:09:55 +0000
Subject: Re: Str_Replace Command
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-176586@lists.php.net to get a copy of this message
Well this is it and it is really got me... Echoing out the $Symbol and $Price works just fine one row about the $TickerData array assignment. Yet it outputs nothing. "Array ( [] => )" is what I get. If I change the line to $TickerData = array ("$Symbol" => "$Price"); I get nothing, or the same result. If I change the line to $TickerData = array ('$Symbo'l => '$Price'); I get the following Array ( [$Symbol] => $Price ) which tells me the assignment works, but it seems like the $Symbol and $Price variable are blank when assigning to the array. I know that they are not blank since they echoed out just fine one line above.....<GRRRRRR> $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); "Jason Wong" <php-general@gremlins.biz> wrote in message news:200402030059.46805.php-general@gremlins.biz... > On Tuesday 03 February 2004 00:52, Christopher J. Crane wrote: > > Ok I got around it by the following, but now I have a new problem. I can > > not get the two dimensional array working. I want to later be able to > > output a variable like this $TickerData["IKN"] and it will output the > > associated $Price. > > > print_r($TickerData); > > So what does the above show? If it isn't what you expect, figure out *why*. > Like how is $TickerData being assigned. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > ------------------------------------------ > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > ------------------------------------------ > /* > We have phasers, I vote we blast 'em! > -- Bailey, "The Corbomite Maneuver", stardate 1514.2 > */

« previous php.general (#176586) next »