Forum Moderators: coopster
Right now, I can open the feed and rip out all the content to variables and display in a nicely formatted fashion using:
// Set up $nations
$nationsOpen = "<NATIONS>";
$nationsClose = "</NATIONS>";
$start = strpos($text,$nationsOpen);
$end = strpos($text,$nationsClose);
$length = $end - $start;
$nations = substr($text,$start,$length);
however, the <NATIONS> section contains colons. So my question is this: how can I parse the feed so that the colons become <br> tags, or the seperate nations are grabbed to individual variables?
Thanks ^_^
[edited by: coopster at 12:05 pm (utc) on April 16, 2005]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
however for parsing XML you might want to look at [php.net...]
<Sorry, no urls please. -- coopster>
What Im trying to is parse the xml and display a page containing the information, however, I would like the <NATIONS> tag to be displayed as seperate strings instead of one large one. The colons are where the strings should start and end.
Im thinking the algorithm will be something like this:
A for loop, which will run the number of times found from <NUMNATIONS>. In this loop, the code will check for the next colon, and create a new variable containing the string between the two current colons. Then, in the body section of the page, another loop will print the strings to the page.
I havent been working with PHP for very long, so I might be missing something quite basic here.
Thanks in advance for any help ^_^
[edited by: coopster at 10:06 pm (utc) on April 17, 2005]
[edit reason] removed url per TOS [/edit]
What is the name of the array where it places my strings, and how can I call values out of the array?
using var_dump(explode(":", $nations)); I get this:
array(6) { [0]=> string(22) "pifflofodofia" [1]=> string(14) "the_pie_eaters" [2]=> string(15) "sooty_and_sweep" [3]=> string(10) "sevenfaust" [4]=> string(15) "fluffly_bunnies" [5]=> string(9) "bunnygirl" }
Which shows that the strings are stored in the array, but echo array(2), array[2], string(2) or string[2] all apear to do the wrong thing.
[us2.php.net...]
when printing to an <a> tag:
[me.host.net...]
(<FLAG> and <NATIONS> being the XML tags)
How can I solve this problem?
[edited by: jatar_k at 4:57 pm (utc) on April 19, 2005]
[edit reason] generalized urls [/edit]