Is there a PHP cut function?

Discussion in 'PHP' started by amys101place, Dec 13, 2010.

  1. #1
    Hi all. I'm in the midst of my ongoing efforts to understand php. I've been analyzing a script and trying to understand everything it's doing from top to bottom. Last night, I noticed it was using a function called 'cut' but I can't find anything on it online.

    If I'm guessing right, it's cutting the part at description to the end description tag for the $item.. but it just seems odd that I can't find anything online.

    $description=cut("<description>","</description>",$lineitem);
    Code (markup):
    preg_match looks like it would typically be used for this.. but why am I not finding anything on cut? Am I just missing it??
    Thanks!
     
    amys101place, Dec 13, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
  3. amys101place

    amys101place Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I had already been there.. not a word on 'cut'.
     
    amys101place, Dec 13, 2010 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    This is not a built in PHP function, but rather a user specific function that whomever created the script came up with (which is what Dan was implying). This usually means no documentation except understanding the function itself.

    If you look around in your files, you will find the declaration for it:

    function cut(params)
    {

    }
     
    ThePHPMaster, Dec 13, 2010 IP
  5. amys101place

    amys101place Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ah... gotcha. Thanks much!
     
    amys101place, Dec 13, 2010 IP
  6. JREAM

    JREAM Member

    Messages:
    160
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #6
    I think it's bad practice to redefine functions something like "cut" that appears to do what's already built in. It's also much faster for PHP to use built-in functions rather than defining our own, since they are written in C vs PHP having to parse ours.

    You may need to check the rest of the code where this bloke created a function cut(), bad practice if you ask me :\
     
    JREAM, Dec 13, 2010 IP
  7. amys101place

    amys101place Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    lol.. I think I have to agree! But.. the good news is that is was an unused function. I searched the rest of the code and it was never called so it all worked out. :) I'm still so new to php but I just love it. Such fun!
     
    amys101place, Dec 13, 2010 IP