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 Link to comment https://forums.phpfreaks.com/topic/192738-functions-are-not-working/ 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 Link to comment https://forums.phpfreaks.com/topic/192738-functions-are-not-working/#findComment-1015304 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... Link to comment https://forums.phpfreaks.com/topic/192738-functions-are-not-working/#findComment-1015306 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 Link to comment https://forums.phpfreaks.com/topic/192738-functions-are-not-working/#findComment-1015337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.