I made a script, and its output is an array inside an array. I would like to know what the output exactly contains.
Anyone could make me a script that does the following? Read an array, including the array inside the first array. *either outputs to screen. *either outputs to text file.
@acemoauthorDec 13.2005 — #ok.. then my script aint working..
The following script was supposed to check all character names on the page ($file), then putting these all in the variable $character, could anyone take a look, what i did wrong here? [code=php] <?php $guild = "Order of Banor"; $guild = ucfirst("$guild"); $trans = array(" " => "+"); $guild = strtr($guild, $trans); echo "$guild <br>"; $file = "http://www.tibia.com/community/?subtopic=guilds&page=view&GuildName=$guild"; $text = file_get_contents($file) or die("Unable to read file."); $character[0] = "Acemo"; if(preg_match_all('/(?<=name=)[^<]+(?=">)/i', $text, $matches)){ foreach( $matches as $nr => $name){ $addchar = ucfirst($matches[$nr]); $trans = array(" " => " "); $addchar = strtr($addchar, $trans); array_push($character, $addchar); } echo "<pre>"; print_r($character); echo "</pre>n"; } ?> [/code]
@NogDogDec 14.2005 — #When you do [b]$trans = array('key' => 'value');[/b] that creates a new array (effectively overwriting any existing array of the same name). So your second assignment to $trans is getting rid of the first. Instead, do: [b]$trans['key'] = 'value';[/b] and that will append that new element to the array.