SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict Divisive Cotton's Avatar
    Join Date
    Jun 2008
    Location
    Andy lives in London, UK
    Posts
    393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Joining together two regex queries

    Instead of going like this:

    PHP Code:
      foreach(scandir($feed->model) as $result) {
      
                if(
    preg_match('/.php$/'$result) && preg_match('/class/'$result)) {
                    
                    echo 
    "YES";
                    
                } else {
                    
                    echo 
    "NO";
                    
                }
                
            } 
    Is it possible to put them together into one preg_match function?
    Let everyday be Christmas

  2. #2
    SitePoint Addict Divisive Cotton's Avatar
    Join Date
    Jun 2008
    Location
    Andy lives in London, UK
    Posts
    393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I slept on it over night and then realised that this question is dumb because the answer is obvious:


    PHP Code:
      foreach(scandir($feed->model) as $result) {
      
                if (
    preg_match('/class-.*\.php$/'$result)) { 
                    
                    echo 
    "YES";
                    
                } else {
                    
                    echo 
    "NO";
                    
                }
                
            } 
    Let everyday be Christmas


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •