katarra Posted October 10, 2009 Author Share Posted October 10, 2009 The echo part works just fine. That was great. However, I need to be able to call it, but when I just use <?=getAdj($class)?> <?=$class?> it doesn't work. Am I calling it wrong in the form section? Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934396 Share on other sites More sharing options...
katarra Posted October 10, 2009 Author Share Posted October 10, 2009 This is how I'm using it. The function up above works excellent. I just can't seem to call it correctly down here in the form. <td> <div align="left"> <?=$name?> is a member of the <?=$race?>. <?=$HeShe?> has been trained as <?=getAdj($class)?> <?=$class?>. </div> <p align="left"><?=$wep?> <?=$arm?></p></td> Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934398 Share on other sites More sharing options...
.josh Posted October 10, 2009 Share Posted October 10, 2009 try changing that to <?php echo getAdj($class); ?> Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934399 Share on other sites More sharing options...
katarra Posted October 10, 2009 Author Share Posted October 10, 2009 That didn't print out anything. Just a blank. Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934400 Share on other sites More sharing options...
.josh Posted October 10, 2009 Share Posted October 10, 2009 post the entire code as-is don't c/p pieces of it post the whole thing. Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934401 Share on other sites More sharing options...
katarra Posted October 10, 2009 Author Share Posted October 10, 2009 <? $command = 1; $peep = ucwords(strtolower($action3[2])); $peepsname = getuser($peep,"name"); $peeps = getlevel(get("plane"),coords(),"pcs"); $pflags = getuser($peep,"flags"); function getAdj($class) { $array['a'] = array('hunter','Royal'); $array['an'] = array('assassin','entertainer','alchemist'); foreach($array as $k => $v) if (in_array(($class),$v)) return $k; return ''; } $a = array('hunter','entertainer','Royal','assassin','alchemist'); foreach ($a as $class) { echo "Adam appears to be " . getAdj($class) . " " . $class . "<br/>"; } if ($peep != $username && (strpos($peeps,"$peep:") === false || strpos(getuser($peep,"flags"),"(invis)") !== false)) echo("You do not see $peep here."); else{ $name = "<i>".getuser($peep,"name")."</i>"; $race = "<i>".getuser($peep,"race")."</i>"; $gender = getuser($peep,"gender"); if ($gender == "male"){ $HeShe = "He"; $heshe = "he"; $hisher = "his"; }else if ($gender == "female"){ $HeShe = "She"; $heshe = "she"; $hisher = "her"; }else{ $HeShe = "It"; $heshe = "it"; $hisher = "its"; } if (getuser($peep,"guild") == "") $guild = "$name is not a member of a guild."; else $guild = "$name is a member of the guild <i>".getuser($peep,"guild")."</i>."; $gender = "<i>$gender</i>"; $home = "<i>".getuser($peep,"hometown")."</i>"; $eyes = "<i>".getuser($peep,"eyes")."</i>"; $hair = "<i>".getuser($peep,"hair")."</i>"; $skin = "<i>".getuser($peep,"skin")."</i>"; $height = "<i>".getuser($peep,"height")."</I>"; $build = "<i>".getuser($peep,"build")."</i>"; $class = "<i>".getuser($peep,"class")."</i>"; $wep = getuser($peep,"weapon"); if($wep)$wep="$name is wielding a <i>$wep</i>.";else $wep="$name has <i>no weapon</i>."; $ret = ""; if ($peep == $username){ $petdata = getuser($peep,"pet"); $ret = "The ".get("race")." known as ".get("name")." is here"; if ($petdata[1] != "") $ret .= " with ".get("pet"); $ret .= ".<br><br>\n"; } $other = ""; $spouse = getuser($peep,"spouse"); if ($spouse == "none") $spouse = "not married."; else $spouse = "married to <i>".getuser($spouse,"name")."</i>. "; $shield="<i>".getuser($peep,"shield")."</i>";if($shield=="<i></i>")$shield="<i>nothing</i>"; $head="<i>".getuser($peep,"head")."</i>";if($head=="<i></i>")$head="<i>nothing</i>"; $neck="<i>".getuser($peep,"neck")."</i>";if($neck=="<i></i>")$neck="<i>nothing</i>"; $body="<i>".getuser($peep,"body")."</i>";if($body=="<i></i>")$body="<i>nothing</i>"; $leftarm="<i>".getuser($peep,"leftarm")."</i>";if($leftarm=="<i></i>")$leftarm="<i>nothing</i>"; $rightarm="<i>".getuser($peep,"rightarm")."</i>";if($rightarm=="<i></i>")$rightarm="<i>nothing</i>"; $wrists="<i>".getuser($peep,"wrists")."</i>";if($wrists=="<i></i>")$wrists="<i>nothing</i>"; $hands="<i>".getuser($peep,"hands")."</i>";if($hands=="<i></i>")$hands="<i>nothing</i>"; $leftfinger="<i>".getuser($peep,"leftfinger")."</i>";if($leftfinger=="<i></i>")$leftfinger="<i>nothing</i>"; $rightfinger="<i>".getuser($peep,"rightfinger")."</i>";if($rightfinger=="<i></i>")$rightfinger="<i>nothing</i>"; $legs="<i>".getuser($peep,"legs")."</i>";if($legs=="<i></i>")$legs="<i>nothing</i>"; $feet="<i>".getuser($peep,"feet")."</i>";if($feet=="<i></i>")$feet="<i>nothing</i>"; $arm="$HeShe has $shield equipped for a shield, $head on $hisher head, $neck around $hisher neck and $body on $hisher body. $HeShe is also wearing $leftarm on $hisher left arm and a $rightarm on $hisher right arm. $HeShe has equipped $wrists on $hisher wrists, $hands on $hisher hands, $leftfinger on $hisher left finger and a $rightfinger on $hisher right finger. $HeShe has $legs on $hisher legs and $feet on $hisher feet. $HeShe is $spouse"; if(strpos(getuser($peep,"flags"),"(equip)")===false)$arm=""; if ($peep != $username){ $myname = get("name"); set("chat",get("chat")."<b><font class=self>You looked at $peepsname.</font></b><br>\n"); $chardata = explode(":",getlevel(get("plane"),coords(),"pcs")); $numchars = count($chardata); for ($i = 0; $i < $numchars; $i++){ if ($chardata[$i] != $username && $chardata[$i] != ""){ $peepname = $chardata[$i]; $cp = getuser($peepname,"chatpref"); if ($chardata[$i] == $peep){$peepchat = "<b>$myname looked at you.</b><br>\n"; if ($cp[10] == 1) setuser($peepname,"newchat",1);} else if(strpos(getuser($peepname,"friends"),"$username:") !== false) $peepchat = "<font class=friends>$myname looked at $peepsname.</font><br>\n"; else $peepchat = "$myname looked at $peepsname.<br>\n"; setuser($peepname,"chat",getuser($peepname,"chat").$peepchat); if ($chardata[$i] != $peep && $cp[11] == 1) setuser($peepname,"newchat",1); } } } } ?> <table width="85%" border="0" cellpadding="10" align="center"> <tr> <td><h2 align="center"><?=$name?></h2></td> </tr> <tr> <td> <div align="left"> <?=$name?> is a member of the <?=$race?>. <?=$HeShe?> has been trained as <?php echo getAdj($class); ?>. </div> <p align="left"><?=$wep?> <?=$arm?></p></td> </tr> <tr> <td><?=$descript = nl2br(getuser($peep,"description"));?></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934403 Share on other sites More sharing options...
.josh Posted October 10, 2009 Share Posted October 10, 2009 okay your problem is this: $class = "<i>".getuser($peep,"class")."</i>"; You have html tags wrapped around the actual class name by the time you pass it to getAdj(). Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934404 Share on other sites More sharing options...
katarra Posted October 10, 2009 Author Share Posted October 10, 2009 I don't quite understand what you mean... Could you show me? Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934406 Share on other sites More sharing options...
.josh Posted October 10, 2009 Share Posted October 10, 2009 what don't you understand? Look at what you are assigning to $class. This is an example of what you are sending to getAdj() : "<i>assassin</i>" do you think "<i>assassin</i>" is the same as "assassin" ? Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934408 Share on other sites More sharing options...
katarra Posted October 10, 2009 Author Share Posted October 10, 2009 Nevermind. Got it. Thank you VERY MUCH! Quote Link to comment https://forums.phpfreaks.com/topic/177200-solved-code-to-help-choose-a-or-an/page/2/#findComment-934409 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.