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 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts

    how to stop print array([0] => preg match

    Hi,

    I have used preg match all function and the data that I want is outputted
    but when it starts with:

    Array ([0]=>

    ....................................
    ....................................data

    How can I hide the array ([0]=> so only the data shows and doesnt print the
    Array([0]=>

    I am using print_r($matches[1]);

    to print the data.

    Any ideas

    thanks in advance

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Preg_match_all has the behaviour of returning a multi-dimensional array. You shouldn't use print_r on it, instead you should extract the matches you're looking for and index into it appropriately.
    In the case you have above, you'd use print $matches[1][0];. You can put it in a loop if you want to retrieve all the records from $matches[1] or $matches[0].
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    tau9 (03-11-2009)


  •  

    Posting Permissions

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