14.07.2009
Channel php ausgewählt, Log vom 14.07.2009
Seite: 1 2 3 > Letzte Seite
Chatlog
Bard|Out: I've got nested array that I can't seem to get anything out of. here's the print_r of it. what am I doing wrong in my echos? echo $xml[10][0][1]; is returning a blank
Bard|Out: http://www.tuatha-kinship.com/xmltest/xml_array_print_r.php
Bard|Out: that'd be [0][0][1], not 10
Bard|Out: /echo $xml["apiresponse"]["_c"]["guild"]; returns nothing either
tsuriga: Should return "Array"
tsuriga: or display.
tsuriga: or print.
Bard|Out: echo $xml returns "Array"
Bard|Out: I'm trying to be able to select specific data at a nested level so I can loop through, grab what I need, and put it somewhere else
tsuriga: The array doesn't have index 0.
Bard|Out: it does down in character
Bard|Out: i just can't get in that far
Bard|Out: line 33 if you saved the output as html via firefox
tsuriga: $xml is an array containing an array at index 'apiresponse', and that array contains an array at index '_c', etc.etc.
tsuriga: So, what you'll need to do is go down in the array structure accessing those arrays from top to bottom, so to speak
Bard|Out: right, so what's the right way to get into the array inside the others at apiresponse, _c, guild, _c, characters, _c, character?
tsuriga: the ['apiresponse']['_c']['guild'] is a good start but as you can see from the printout, that's an array too.
Bard|Out: just like I was doing with $xm['apiresonse]['_c'] etc?
Bard|Out: yeah
Bard|Out: there's no better way than drilling down by hand that way?
tsuriga: Other than reformatting that array, no.
Bard|Out: okay. I'll give that a shot. thanks
tsuriga: You don't need to use the long format more than once though, since you can save a reference to it, $characters =& $xml['apiresponse']['_c']['guild']['_c']['characters']['_c']['character'];
Bard|Out: this should be kosher, right? $charactername =& $xml["apiresponse"]["_c"]["guild"]["_c"]["characters"]["_c"]["character"][$arrpos]["_a"]["name"];
Bard|Out: and then i can for($arrpos=0;$arrpos<=272;$arrpos++) ?
Bard|Out: or am I going to have to stop before $arrpos?
Bard|Out: and run the loop as a seperate outside operation
tsuriga: yeap
tsuriga: (for latter)
Bard|Out: okay. thanks
tsuriga: In PHP5.3 I think you can do: $characterName = function($c) { return $c['_a']['name']; }
Bard|Out: what's the print version via php debug command again? <?php debug; ?> ?
Bard|Out: I'm not sure what I'm on. I got this into three lines, so it's serviceable
tsuriga: I thought there were more but since that's the total count of chars (and especially if that's subject to change), you're better off using foreach loop
Bard|Out: I'm on PHP 5.2.6 anyway
tsuriga: Save numeric loops for cases where you need to actually use the number as well
Bard|Out: I'm planning on putting these into a dropdown once I have the names seperated and using the name from there to form an HTTP request which will download a second xml file and parse that into something visible
Bard|Out: i suppose i could do that with the character name itself though, instead of the array position
Bard|Out: is there any way to have a php script on the webserver to get an unprotected text file from another site and save it to a specific location on said webserver?
Bard|Out: I can only find ways to do it that involve OPENING the file and loading it into an array, etc
xion-wrk: Bard|Out file_get_contents
Bard|Out: that still reads it into a string. is that the best i have for choices?
xion-wrk: what do you want to do? just download it?
Bard|Out: from the server onto the server, yeah
Bard|Out: to a specific folder
Bard|Out: manual refresh of xml data from an external source
xion-wrk: you could get it with wget or something similar using shell_exec
Bard|Out: my php user doesn't have permissions for obvious reasons. i wasn't sure if tehre was someway to do it without processing the file contents through a string/array before they're needed for operations
Bard|Out: i may just resort to a daily cron job to refresh the data
xion-wrk: that's how I'd do it
Earache: i have fetch from sql, $fetch['timestamp']; right, its value is 1247564456 for example, i want to multiply it by 1000, i do echo $fetch['timestamp']*1000; and it gives me 1.247564456E+12, why?
daedeloth: what is heap corruption? and is it my responsibility?
@Lumpio-: Earache: Because... that's the result of the calculation
@Lumpio-: ?
Earache: but why does it give it in that format? shouldnt it just add 3 zeros?
aXn-WonderKid^o: hey! is there a similiar solution to __DIR__? with the $_SERVER commands? Or another command?
rh: "similiar solution" - what's the problem about __DIR__?
aXn-WonderKid^o: you can't use it in earlier versions of php
rh: dirname($_SERVER['PHP_SELF']);
rh: or something like that ;)
opal_froot: ok I have a question - does anyone know if its possible to store a mysql result object to the session and reference it over and over ?
blip2: not as an object but you could convert it into json or something and store it like that
blip2: ie plain text
daedeloth: php & memory wholes... what's the best way to find them? For example, how do I find out what instances are running?
daedeloth: I mean, are in the memory
opal_froot: just wanted it as a result object that I can run mysql_fetch_array on
blip2: opal_froot: no
rh: serialize()
blip2: ^- yeh that
rh: query -> fetch -> array -> serialize
Seite: 1 2 3 > Letzte Seite
Zurück zur ÜbersichtWebseiten Tipps
Hier gehts zum jquery Tutorial.
Meine schwarze Webseite: iPhone4Spiel
