Neffman Posted December 30, 2009 Share Posted December 30, 2009 Ok so I have declared it, (I dont know if it was properly) and i can access it but i dont know whats going on with initialization. $urlArray = array( 0 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=315031', 1 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=143137', 2 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=263836', 3 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=208806', 4 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=264903', 5 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=263881', 6 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=284454', 7 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=255742', 8 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=79370', 9 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=242159', 10 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=203148', 11 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=95222', 12 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=203143', 13 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=323427', 14 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=324216', 15 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=333548', 16 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=338487', 17 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=79370', 18 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=341382', 19 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=332099', 20 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=307436', 21 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=342255', 22 => '0', 23 => '0', 24 => '0'); $charArray = array_fill(0, 25, array_fill(0, 6, 0)); function fillCharData($charArray, $urlArray, $tempUrl) { for($i = 0; $i < 25; $i++) { $tempUrl = $urlArray[$i]; if($tempUrl != '0') { $charData = simplexml_load_file($tempUrl); $charArray[$i][0] = $charData->name; $charArray[$i][1] = $class_name[(int)$charData->classid]; $charArray[$i][2] = $charData->exp; $charArray[$i][2] = (int)$charArray[$i][2]; $charArray[$i][3] = $charLvl->level; $charArray[$i][4] = $charData->mqpasses; $charArray[$i][5] = $charData->mqattempts; } } echo "$charArray[0][0]"; } I just put in the echo for testing the output. It outputs Array[0] Can anyone help? Also if you could look over this other bit of code just to make sure that would be great. function sortArray($charArray, $tempCharArray) { for($x = 0; $x < 25; $x++) { for($y = 0; $y < 25; $y++) { if($charArray[$x][2] < $charArray[$y][2]) { $tempCharArray = $charArray[$x][2]; $charArray[$x][2] = $charArray[$y][2]; $charArray[$y][2] = $tempCharArray; } } } } function printNames($charArray, $image, $fontSize, $col, $row, $black, $defaultFont) { for($i = 0; $i < 25; $i++) { $row = $row * ($i + 1); for($j = 0; $j < 6; $j++) { $col = $col * ($j + 1); ImageTTFText ($image, $fontSize, 0, $col, $row, $black, $defaultFont, $charArray[$i][$j]); } } } The first bubbles the $charArray. The second function is my out put function. Any help would be greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/186641-multidimensional-array-help/ Share on other sites More sharing options...
sKunKbad Posted December 30, 2009 Share Posted December 30, 2009 try print_r() or var_dump() like this: <?php print_r($urlArray); // or var_dump($urlArray); Link to comment https://forums.phpfreaks.com/topic/186641-multidimensional-array-help/#findComment-985759 Share on other sites More sharing options...
Neffman Posted December 30, 2009 Author Share Posted December 30, 2009 Out put of var_dump($charArray[0]); array(6) { [0]=> int(0) [1]=> int(0) [2]=> int(0) [3]=> int(0) [4]=> int(0) [5]=> int(0) } Out put of print_r($charArray[0]); Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) Out put of var_dump($urlArray[0]); NULL Out put of print_r($urlArray[0]); empty screen So to my sight its not a problem with $charArray but with $urlArray Anyone see a problem in my code? $urlArray = array( 0 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=315031', 1 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=143137', 2 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=263836', 3 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=208806', 4 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=264903', 5 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=263881', 6 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=284454', 7 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=255742', 8 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=79370', 9 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=242159', 10 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=203148', 11 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=95222', 12 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=203143', 13 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=323427', 14 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=324216', 15 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=333548', 16 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=338487', 17 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=79370', 18 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=341382', 19 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=332099', 20 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=307436', 21 => 'http://ladderslasher.d2jsp.org/xmlChar.php?i=342255', 22 => '0', 23 => '0', 24 => '0'); Link to comment https://forums.phpfreaks.com/topic/186641-multidimensional-array-help/#findComment-986164 Share on other sites More sharing options...
premiso Posted December 30, 2009 Share Posted December 30, 2009 Your problem lies within Variable Scopes You define $urlArray outside of the function and it has to be either global, passed as a parameter or defined inside the function to use it there. Link to comment https://forums.phpfreaks.com/topic/186641-multidimensional-array-help/#findComment-986169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.