Using arrays, please help

Discussion in 'PHP' started by sanyi007, Jul 13, 2009.

  1. #1
    Hi all, i have these two preg_match line:

    preg_match_all('#<title>(.*?)</title>#is', $theData, $matches);  
    
    preg_match_all('#<content:encoded><!\[CDATA\[(.*?)]]></content:encoded>#is', $theData, $matcher);
    PHP:
    Both $matches and $matcher is an array with the same (700) content, i would like to print them in a table... How can i do this? I used foreach, but something was wrong because i always got "Array" or the first element for one of them, and just the other was printed right.
    How can i print them? (something like echo $matches.$matcher; but with the array working.)

    Sorry for the noob question, i'm a beginner, and i always had problems with arrays.
     
    sanyi007, Jul 13, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    to loop through a normal array:
    foreach($array as $a){
    echo $a;
    }

    to loop through assoc array with keys
    foreach($array as $key => $value){
    echo "Key: $key Value:$value";
    }

    to loop through multi dimensional array:
    foreach($array as $arr){
    foreach ($arr as $a){
    echo $a;
    }
    }
     
    wd_2k6, Jul 13, 2009 IP