SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multi dimensional array

    Hi

    This code prints all string with in <ite></ite> in xml files.

    $matches is a two dimensinal array and $matches[1][variable]

    How to store it in a array and make it one dimensional array

    Code:
    foreach ($str as $string){
    preg_match_all("#<ite>(.*?)(?=</ite>)#",$string,$matches);
    print $matches[1][4];
    }
    $matches[1][This value is between 0-9].

    The result is displayed when value entered 0-9.

  2. #2
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I store only the string in a array

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    How many matches are you expecting?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to store all the values in an array. At present only 10 values are present

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $matches[1] is itself an array, which contains all the matches captured by (.*?).
    print_r($matches[1]);

    Or, are you looking to build an array which combines the results of each iteration of your foreach loop?


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
  •