emexinc Posted February 20, 2010 Share Posted February 20, 2010 ...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 Quote Link to comment Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 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 Quote Link to comment Share on other sites More sharing options...
emexinc Posted February 20, 2010 Author Share Posted February 20, 2010 ...i don't quite understand your explanation...i don't have any double $ in my coding... Quote Link to comment Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 $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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.