Jump to content

[SOLVED] Multiple Array with 5 Values in each...


gary_rip

Recommended Posts

I'm not even sure i have the right title for this thread but...

 

Here is my code

 

<?php
echo '<table border="1">';
echo '<tr>';
echo '<td>'.$match4[1].'</td>';
echo '<td><a href="http://www.awebsite.com/'.$match3[1].'" target="_blank">'.$match2[1].'</a></td>';
?>

 

I'm making a table from the data in the arrays, but i want to loop it so that every $match[X] jumps up a number and creates another row on the table.

 

Sorry for the rubbish explanation... it doesn't help when i don't know the correct terminology!

$cnt = count($match);
for ($i=0; $i < $match; $i++) {
    echo '<td>'.$match4[$i].'</td>';
    echo '<td><a href="http://www.awebsite.com/'.$match3[$i].'" target="_blank">'.$match2[$i].'</a></td>';
}

 

Damnit, sorry for the double post. I thought I clicked the edit button =\

as i cant see where $match comes from...

 

You may need it to be $match1, given your initial post I thought that there was also a $match, but that is probably a wrong assumption. Change it to $match1 and see if that works.

$cnt = count($match1);
for ($i=0; $i < $cnt; $i++) {
    echo '<tr><td>'.$match4[$i].'</td>';
    echo '<td><a href="http://www.awebsite.com/'.$match3[$i].'" target="_blank">'.$match2[$i].'</a></td></tr>';
}

 

By outputting the first row, I will take it as it is working, it just needs to separate the data into rows. That should, hopefully work. You are giving me some vague feedback, by the way can you post how your arrays are populated/setup? If the above does not work that is, it would help diagnosing the issue.

Sorry for being vague, but you gave me all the answers that i needed to get my origional question resolved!

 

Its just that as you correctly stated it was a problem with my array was populated... i was using preg_match and not preg_match_all

 

RESOLVED! :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.