Shorten this line?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • UKuser

    Shorten this line?

    Hi,

    Is there a way to shorten this line

    if ((ereg(".jpg",$ filename))||(er eg(".eps",$file name))||(ereg(" .tif",
    $filename))||(e reg(".tiff",$fi lename))||(ereg (".jpeg",$filen ame))||
    (ereg(".ai",$fi lename))) {

    I've tried ereg(array("1", "2" etc),$filename) but it won't work. A bit
    of context - I'm trying to filter files of certain types.

    Thanks

    A

  • Rami Elomaa

    #2
    Re: Shorten this line?

    "UKuser" <spidercc21@yah oo.co.ukwrote in message
    news:1179305059 .030405.170200@ q23g2000hsg.goo glegroups.com.. .
    Hi,
    >
    Is there a way to shorten this line
    >
    if ((ereg(".jpg",$ filename))||(er eg(".eps",$file name))||(ereg(" .tif",
    $filename))||(e reg(".tiff",$fi lename))||(ereg (".jpeg",$filen ame))||
    (ereg(".ai",$fi lename))) {

    if(preg_match(' #.+\.(jpg|jpeg| eps|tif|tiff|ai )$#', $filename)){

    --
    Rami.Elomaa@gma il.com

    "Good tea. Nice house." -- Worf


    Comment

    • UKuser

      #3
      Re: Shorten this line?

      On 16 May, 09:52, "Rami Elomaa" <rami.elo...@gm ail.comwrote:
      "UKuser" <spiderc...@yah oo.co.ukwrote in message
      >
      news:1179305059 .030405.170200@ q23g2000hsg.goo glegroups.com.. .
      >
      Hi,
      >
      Is there a way to shorten this line
      >
      if ((ereg(".jpg",$ filename))||(er eg(".eps",$file name))||(ereg(" .tif",
      $filename))||(e reg(".tiff",$fi lename))||(ereg (".jpeg",$filen ame))||
      (ereg(".ai",$fi lename))) {
      >
      if(preg_match(' #.+\.(jpg|jpeg| eps|tif|tiff|ai )$#', $filename)){
      >
      --
      Rami.Elo...@gma il.com
      >
      "Good tea. Nice house." -- Worf
      Thanks for that!

      A

      Comment

      • shimmyshack

        #4
        Re: Shorten this line?

        On May 16, 10:05 am, UKuser <spiderc...@yah oo.co.ukwrote:
        On 16 May, 09:52, "Rami Elomaa" <rami.elo...@gm ail.comwrote:
        >
        >
        >
        "UKuser" <spiderc...@yah oo.co.ukwrote in message
        >
        news:1179305059 .030405.170200@ q23g2000hsg.goo glegroups.com.. .
        >
        Hi,
        >
        Is there a way to shorten this line
        >
        if ((ereg(".jpg",$ filename))||(er eg(".eps",$file name))||(ereg(" .tif",
        $filename))||(e reg(".tiff",$fi lename))||(ereg (".jpeg",$filen ame))||
        (ereg(".ai",$fi lename))) {
        >
        if(preg_match(' #.+\.(jpg|jpeg| eps|tif|tiff|ai )$#', $filename)){
        >
        --
        Rami.Elo...@gma il.com
        >
        "Good tea. Nice house." -- Worf
        >
        Thanks for that!
        >
        A
        you can still shorten it a teeny bit more, by
        \.(jpe?g|eps|ti ff?|ai)$
        instead of
        ..+\.(jpg|jpeg| eps|tif|tiff|ai )$
        buy hey who cares right

        Comment

        Working...