Merge Arrays (my ugly arrays)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tmaiden
Forum Commoner
Posts: 64
Joined: Fri Feb 24, 2006 3:15 pm
Location: Philadelphia
Contact:

Merge Arrays (my ugly arrays)

Post by tmaiden »

I'm still learning everyone so please bear with me.

Before I start with my actual question, maybe cleaning up my regexs may be the answer to fixing my arrays.

My Arrays

Code: Select all

preg_match_all("/<a.*? href=\"((.*?).torrent)\".*?>(.*?)<\/a>/i",$inputStream,$torrentlink);
preg_match_all("/<a.*? title=\"Details for (.*?)\">(.*?)<\/a>/i",$inputStream,$torrentname);
preg_match_all("/<td align=\"right\">(.*?)<\/td>/i",$inputStream,$sizeseedleech);
preg_match_all("/<td>((.*?)&nbsp;(.*?))<\/td>/i",$inputStream,$uploaded);
I would like to combine these arrays into one multi dimensional array.
$cleanArray[index][badarrayattrib]

The even ugliest thing is the $sizeseedleech array since it pulls 3 values. If I wanted to print the contents of the arrays, I do this.

Code: Select all

for($i = 0; $i <= 29; $i++)
{
        echo $torrentlink[1][$i] . "<br>" . $torrentname[1][$i] . "<br>" . $sizeseedleech[1][($i*3)] .
        "<br>" . $sizeseedleech[1][($i*3)+1] . "<br>" . $sizeseedleech[1][($i*3)+2] .
        "<br>" . $uploaded[1][$i] ."<br><br>";
}
Any way that any of this code could be changed? I would then in the future like to pass the new array to a db.

Any help would be greatly appriciated! Thanks in advance.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Merge Arrays (my ugly arrays)

Post by RobertGonzalez »

What do the arrays look like originally and what do you want them to look like?
Post Reply