FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Php Arrays :((((((((





cr3ativ3
Ok, I have never been able to harness how to use arrays but in this circumstance I need to I am trying to display the contents of the arrays but.. i can't get it to do I have been fidling for the last two hours and searching the web with no resolve it is probably just a simple issue I can't see but... ya

So here is my script so just basically want to be able to display the array items i chose.

Code:

<?php
$untreatedstats = file_get_contents("http://hiscore-web.runescape.com/aff/runescape/hiscorepersonal.ws?user1=upcast");

preg_match_all('/<td align=\"left\"><a href=\"overall.ws\?table=0&user=upcast\">
Overall
<\/a><\/td>
<td align=\"right\">(.*)<\/td>
<td align=\"right\">(.*)<\/td>
<td align=\"right\">(.*)<\/td>
<\/tr>
<tr>/iU', $untreatedstats, $matches);
//Content

echo $match[1];

?>
MrBlueSky
Two things:

1.

Quote:

<?php
$untreatedstats = file_get_contents("http://hiscore-web.runescape.com/aff/runescape/hiscorepersonal.ws?user1=upcast");

preg_match_all('/<td align=\"left\"><a href=\"overall.ws\?table=0&user=upcast\">
Overall
<\/a><\/td>
<td align=\"right\">(.*)<\/td>
<td align=\"right\">(.*)<\/td>
<td align=\"right\">(.*)<\/td>
<\/tr>
<tr>/iU', $untreatedstats, $matches);
//Content

echo $matches[1];

?>


2. If it still doesn't work, can you post a sample content of $untreatedstats?
cr3ativ3
oh ya i forgot to change it back to matches from one of the previos experiments but when I ever i try to display the array (matches[1], matches[2] etc...) it just shows me "Array".

Also for the untreadted stats just go to this link and view the source that is the untreated stats.

http://hiscore-web.runescape.com/aff/runescape/hiscorepersonal.ws?user1=upcast

Thank You
MrBlueSky
Code:


<?php
$untreatedstats = file_get_contents("http://hiscore-web.runescape.com/aff/runescape/hiscorepersonal.ws?user1=upcast");

preg_match('/user=upcast\">[\w\W]*<\/tr>[\w\W]*Overall([\w\W]*)<\/tr>/iU', $untreatedstats, $matches);
preg_match_all('/right\">(.*)</iU', $matches[0], $matches2);


echo $matches2[1][0]."<BR>";
echo $matches2[1][1]."<BR>";
echo $matches2[1][2]."<BR>";

?>



Should work Smile
cr3ativ3
MrBlueSky wrote:
echo $matches2[1][0]."<BR>";
echo $matches2[1][1]."<BR>";
echo $matches2[1][2]."<BR>";


Ty, it works any chance you could explain that incase i want to add more $matches2[]
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.