ridiculous Posted February 28, 2007 Share Posted February 28, 2007 Hi. I'm trying to convert this array into variables using extract. I've read throught the PHPmanual and I'm having trouble matching this script to the manual. Maybe a kind soul could show me the light. <? Class quote{ function get($symbol){ $url = sprintf("http://finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv", $symbol); $fp = fopen($url, "r"); if(!$fp){ echo "Error: Cannot connect"; } else { $array = fgetcsv($fp, 4096, ','); fclose($fp); $this->symbol = $array[0]; $this->last = $array[1]; $this->date = $array[2]; $this->time = $array[3]; $this->change = $array[4]; $this->open = $array[5]; $this->high = $array[6]; $this->low = $array[7]; $this->volume = $array[8]; } } } ?> Link to comment https://forums.phpfreaks.com/topic/40471-little-help-with-extract/ Share on other sites More sharing options...
ridiculous Posted February 28, 2007 Author Share Posted February 28, 2007 Ok, so this isn't an array and I can't use extract. Any ideas? Link to comment https://forums.phpfreaks.com/topic/40471-little-help-with-extract/#findComment-195819 Share on other sites More sharing options...
emehrkay Posted February 28, 2007 Share Posted February 28, 2007 $this->var is pretty much a variable. you can use it in the scope of the class. to use it outside of the class, you could do return array('symbol' => $array,...); Link to comment https://forums.phpfreaks.com/topic/40471-little-help-with-extract/#findComment-195822 Share on other sites More sharing options...
ridiculous Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks. Solved. This is what I was looking to do: $variable=($q->last); Finally. My ass hurts. That was ridiculous (my namesake). By the way, I've attempted to change the subject line to solved but the "MODIFY" option has disappeared. Link to comment https://forums.phpfreaks.com/topic/40471-little-help-with-extract/#findComment-195836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.