Jump to content

Functions are not working


emexinc

Recommended Posts

...somebody please kick me in the right direction...

 

function price_insert($species, $letter){
$spe = ${$species};
if($spe == "y"){for($s = 0; $s < $bcount; $s++)
{list($n, $p) = split('[,]', $wordChunks[$s]);
if($n == $item_number_1.$letter){$spe = $p;$s == $bcount;}}}
}

price_insert("poplar", "p");

 

...I am trying to get the function to end up working as if everything was like it is below...

 

if($poplar == "y"){for($s = 0; $s < $bcount; $s++)
{list($n, $p) = split('[,]', $wordChunks[$s]);
if($n == $item_number_1."p"){$poplar = $p;$s == $bcount;}}}

 

...i've looked into creating variables from text, but somehow i'm not getting it to work...thanks again for your help...darwin

 

Link to comment
https://forums.phpfreaks.com/topic/192738-functions-are-not-working/
Share on other sites

Not sure exactly what you are trying to do with a variable var but

$species='poplar';

$$species='cottonwood';

$spe=${$species};

echo $spe;//cottonwood

 

as you are doing it

 

$species ==poplar but $$species==''//has no value

 

The way you call the function you need

$species='poplar';

$$species='y';

price_insert($species, "p");

 

 

HTH

Teamatomic

$spe = ${$species};

if($spe == "y"){for($s = 0; $s < $bcount; $s++)

yes, you do.

this

${$species}

and this

$$species

are the same

 

You have to rewrite your function. There is no way to pass

$$species to a function.

 

 

HTH

Teamatomic

 

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.