Jump to content

Very Simple, Trying To Use A Variable As An Input In An Array Parameter


Recommended Posts

I have this super simple function

 

 

  function getstockstats($stocksymbol)
 {
include_once('ii-prediction-log-widget/class.yahoostock.php');
$objYahooStock = new YahooStock;
$objYahooStock->addFormat("snl1d1t1cvc1p2");
$objYahooStock->addStock("$stocksymbol");

foreach( $objYahooStock->getQuotes() as $code => $stock)
{
echo $stock[0];
}

 }

 

when I use the function, I pass it a symbol like this

 

getstockstats("aapl");

 

I want this line

$objYahooStock->addStock("$stocksymbol");

to receive the variable (aapl), instead, its reading it as $stocksymbol

 

I know there is a way to exit that but I can't for the life of me figure it out because it is so hard to explain that portion. Can someone help me?

 

I've tried wrapping it in {}

 

like this

 

$objYahooStock->addStock("{$stocksymbol}");

 

but that did not work either. Thank you!! <3

Edited by phpchick

Have you tried removing the double-quotes?

 

Instead:

 

$objYahooStock->addStock($stocksymbol);

 

Not sure that will make a difference. Doesn't with procedural functions. Methods might be different (somebody else chime in here).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.