preg_match_all returns 1 or empty array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mladen Mavrovic
    New Member
    • Apr 2011
    • 7

    #1

    preg_match_all returns 1 or empty array

    This code returns 1 with print_r($urls)
    Code:
    $pattern = '#^http://domain.com/(.*)(\w*)0\b#';
    preg_match_all($pattern, $email, $urls);
    same code returns empty array with those two outputs:

    1. print_r($urls, true)

    2. print_r($urls[0], true)

    like this:

    1
    Array
    (
    [0] => Array
    (
    )

    [1] => Array
    (
    )

    [2] => Array
    (
    )

    )

    2
    Array
    (
    )

    However, when I test code here, it works like charm

    How can I get my values? It will be very nice to have them in a variables, like $url1, $url2...

    Can anybody help? (Your time and effort is highly appreciated!)
  • Mladen Mavrovic
    New Member
    • Apr 2011
    • 7

    #2
    Issue solved 2 days ago. When I remove this:
    Code:
    ^
    from my regexp $urls[0][0] outputs first url :)

    Comment

    Working...