1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to use a function? Help needed.

Discussion in 'PHP' started by baris22, Dec 27, 2008.

  1. #1
    Hello,

    I have got a function, i do not know how to use it. can anybody help me.

    Thanks

    
    
    function removeSmallWords($baseString){
        $toReturn = "";
        $wordArray = spliti(" ", $baseString);
        foreach ($wordArray as $word) {
            if(strlen($word) >= 3){
                $toReturn .= $word . " ";
            }
        }
    	
        return $toReturn;
    }
    
    PHP:
    I want to use this function on

    $title
     
    baris22, Dec 27, 2008 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    echo removeSmallWords($title);

    or add it in a variable that you can later use .. $words = removeSmallWords($title);
     
    commandos, Dec 27, 2008 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thank you.

    
    
    $words = removeSmallWords($title);
    
    
    PHP:
    worked perfect. I have got another question. I have got many other functions.

    How can i use them all once instead of using one by one.

    Thanks


     
    baris22, Dec 27, 2008 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    what do you mean ? what are those functions ?
     
    commandos, Dec 27, 2008 IP
  5. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I mean I have got different functions and if i want to use them one by one i need to do this

    
    
    $words = removeSmallWords($title);
    $words = anotherfunction($title);
    $words = anotherfunction($title);
    $words = anotherfunction($title);
    $words = anotherfunction($title);
    ...
    ...
    
    
    PHP:

     
    baris22, Dec 27, 2008 IP
  6. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #6
    no you can edit your first function and add a call to the other functions ..

    or better make a functions that calls all functions

    function call_All($words) {

    $returnedvalue = function1($words);
    $returnedvalue = functuon2($whatever);
    ....

    return $returnedvalue;



    }
     
    commandos, Dec 27, 2008 IP
  7. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #7
    Or just build all those functions into a main one? Would probably mean each individual function could be rewritten too.
     
    Danltn, Dec 27, 2008 IP