PHP Function help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zurih
    Member
    • Oct 2004
    • 75

    PHP Function help

    I'm trying to add an automated text in $xxx['xxx'] function with a condition.
    So baisicly what php code I have to use to add this to a function?

    I tried this but its not working
    PHP Code:
    if($xyxy['xyxy']==bla)
    {
    $xxx['xxx']=$yyy['yyy']." blahblahblah";

    I mean that the "blahblahblah" will be the auto text addon to the function when when the condition accures.

    Can anyone tell me if the code is good and if not what is the right one?

    thanks
  • Neocorteqz
    Senior Member
    • Aug 2002
    • 332
    • 3.0.3

    #2
    no php expert, but it looks right.

    PHP Code:
    if ($variable == "one thing") { // code to do something } 
        
    else if ($variable == "something else") { // code to do something else } 
        
    else if ($variable == "yet another thing") { // code to do still something else } 
        
    else { // default code } 
    Last edited by Neocorteqz; Tue 8 Mar '05, 4:24pm.

    Comment

    • zurih
      Member
      • Oct 2004
      • 75

      #3
      Its ok what u wrote but in "code to do something" I need a code that will add a word to the variable that already excists.

      Now what is that code I want to know...
      Last edited by zurih; Wed 9 Mar '05, 12:57am.

      Comment

      • Icheb
        Senior Member
        • Nov 2002
        • 1291

        #4
        You already posted that code, just use ' instead of " in both instances.

        Comment

        • zurih
          Member
          • Oct 2004
          • 75

          #5
          Originally posted by Icheb
          You already posted that code, just use ' instead of " in both instances.
          I know but its not working for some reason. Its not changing anything...

          Comment

          • dklofas
            New Member
            • Mar 2005
            • 1

            #6
            you may not have the variables in scope in the function. use
            PHP Code:
            global $xxx$yyy
            also, if your not returning the edited string, you'll need to pass the variables by refrence to the function

            PHP Code:
            function sumfunc(&$xxx, &$yyy) {
                ...

            Comment

            • Icheb
              Senior Member
              • Nov 2002
              • 1291

              #7
              Did you surround the "bla" in your if condition with single quotes?

              Comment

              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
              Working...