Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    Regular Expression Problem

    How come im not getting any results back for this code?

    PHP Code:
        function getMatches($strMatch,$strContent) {
            if(
    preg_match_all($strMatch,$strContent,$objMatches)){
                return 
    $objMatches;
            }
            return 
    "";
        }

    $strContent "<li class="tel"><strong>Tel:&nbsp;</strong><span><!-- sphoneid telnr="+353 (021)4501172" fileas="Abbey Business Communications" -->(021)4501172<!-- sphoneid --></span></li>";  
    $strMatch "<li class=\"tel\"><strong>Tel:&nbsp;</strong><span><!-- sphoneid telnr=\"(.*)\" fileas=\"(.*)\" -->(.*)<!-- sphoneid --></span></li>isU";

          
    getMatches($strMatch,$strContent);
          
          
          if (
    $objMatches !=0)
          {
          
          echo 
    '<pre>';print_r ($objMatches);echo '</pre>';    
          }
          
          else 
          {
          echo 
    "no matches";
          } 

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    #<\!--\ssphoneid\stelnr=\"([^\"]*)\"\sfileas=\"([^\"]*)\"\s-->([^<]*)<\!--\ssphoneid\s-->#is 
    Code:
    Array
    (
        [0] => <!-- sphoneid telnr="+353 (021)4501172" fileas="Abbey Business & Communications" -->(021)4501172<!-- sphoneid -->
        [1] => +353 (021)4501172
        [2] => Abbey Business & Communications
        [3] => (021)4501172
    )
    Last edited by Phil Jackson; 11-02-2009 at 02:56 PM.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    $strContent "<li class="tel"><strong>Tel:&nbsp;</strong><span><!-- sphoneid telnr="+353 (021)4501172" fileas="Abbey Business Communications" -->(021)4501172<!-- sphoneid --></span></li>";  
    $strMatch "<li class=\"tel\"><strong>Tel:&nbsp;</strong><span><!-- sphoneid telnr=\"(.*)\" fileas=\"(.*)\" -->(.*)<!-- sphoneid --></span></li>isU"
    Your code has some syntax errors. Turn on error reporting, if you haven't done.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    hints towards the blue words abduraooft's quote
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #5
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Phil Jackson View Post
    PHP Code:
    #<\!--\ssphoneid\stelnr=\"([^\"]*)\"\sfileas=\"([^\"]*)\"\s-->([^<]*)<\!--\ssphoneid\s-->#is 
    Code:
    Array
    (
        [0] => <!-- sphoneid telnr="+353 (021)4501172" fileas="Abbey Business & Communications" -->(021)4501172<!-- sphoneid -->
        [1] => +353 (021)4501172
        [2] => Abbey Business & Communications
        [3] => (021)4501172
    )
    Works like a charm..

    Thanks a mill....


  •  

    Posting Permissions

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