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
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

Link to comment
Share on other sites

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.