Re: [PHP] Converting an unordered list into JSON
[snip] Ahh, the list is in an HTML document, suddenly it all becomes clear. DOMDocument is probably your best bet here. Other HTML parsers are also available. -Stuart [/snip] Ah! Thanks for the heads up on that Stuart - I'll start my work there this afternoon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
On 5 Mar 2012, at 16:45, Jay Blanchard wrote: > [snip] > Difficult to answer without knowing how your data is currently stored. Gimme > a var_dump or var_export of your data and I'll be able to give you an answer. > -Stuart > [/snip] > > It is an unordered nested list as in the following example - > > > foo > bar > > glorp > > > Ahh, the list is in an HTML document, suddenly it all becomes clear. DOMDocument is probably your best bet here. Other HTML parsers are also available. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
[snip] Sounds like your tangents are efforts to accomplish things that you know too little about and don't want to spend too much time getting acquainted with. To borrow from your crude response to Mr. Dallas: You may have RTFM, now try DTFW. :) [/snip] Seriously Jim? I have been a member and contributor to this very list for a very long time. I do know about my tangents and I am quite acquainted with what is entailed but hoping that the community might have some insight that would cause me to look at things in a fresh light. I appreciate your rude response to my rude response. You are quite clever :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
[snip] Difficult to answer without knowing how your data is currently stored. Gimme a var_dump or var_export of your data and I'll be able to give you an answer. -Stuart [/snip] It is an unordered nested list as in the following example - foo bar glorp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
"Jay Blanchard" wrote in message news:4f54e388.7010...@sigmaphinothing.org... > On 3/5/2012 9:53 AM, Stuart Dallas wrote: >> On 5 Mar 2012, at 15:50, Jay Blanchard wrote: >> >>> I am off on my next tangent now and I have not really thought about this >>> too much yet but have you seen a method to convert a nested unordered >>> list into JSON using PHP? >> There's a very useful search function for the PHP manual on the PHP site. >> Typing json into that would have got you to http://php.net/json_encode. >> If that can't natively handle your variable type then you'll need to >> massage the data into simple types first. >> > Stuart I have RTFM, I was hoping that someone had an example handy. :) Jay, Sounds like your tangents are efforts to accomplish things that you know too little about and don't want to spend too much time getting acquainted with. To borrow from your crude response to Mr. Dallas: You may have RTFM, now try DTFW. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
On 5 Mar 2012, at 16:24, Jay Blanchard wrote: > [snip] > $json = json_encode($nested_unordered_list); As I said, whether that works or > not depends on what type $nested_unordered_list is. If it's not made of > standard types you'll need to massage it into a structure using standard > types. :D > [/snip] > > Stewie, Stewie, Stewie. :) Bla, Bla, Bla….. :) > So what you're saying is that I will need to turn the nested unordered list > into an array? Because an array would more accurately represent the data. Difficult to answer without knowing how your data is currently stored. Gimme a var_dump or var_export of your data and I'll be able to give you an answer. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] Converting an unordered list into JSON
[snip] $json = json_encode($nested_unordered_list); As I said, whether that works or not depends on what type $nested_unordered_list is. If it's not made of standard types you'll need to massage it into a structure using standard types. :D [/snip] Stewie, Stewie, Stewie. :) So what you're saying is that I will need to turn the nested unordered list into an array? Because an array would more accurately represent the data. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
On 5 Mar 2012, at 16:02, Jay Blanchard wrote: > On 3/5/2012 9:53 AM, Stuart Dallas wrote: >> On 5 Mar 2012, at 15:50, Jay Blanchard wrote: >> >>> I am off on my next tangent now and I have not really thought about this >>> too much yet but have you seen a method to convert a nested unordered list >>> into JSON using PHP? >> There's a very useful search function for the PHP manual on the PHP site. >> Typing json into that would have got you to http://php.net/json_encode. If >> that can't natively handle your variable type then you'll need to massage >> the data into simple types first. >> > Stuart I have RTFM, I was hoping that someone had an example handy. :) $json = json_encode($nested_unordered_list); As I said, whether that works or not depends on what type $nested_unordered_list is. If it's not made of standard types you'll need to massage it into a structure using standard types. :D -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] Converting an unordered list into JSON
On 3/5/2012 9:53 AM, Stuart Dallas wrote: On 5 Mar 2012, at 15:50, Jay Blanchard wrote: I am off on my next tangent now and I have not really thought about this too much yet but have you seen a method to convert a nested unordered list into JSON using PHP? There's a very useful search function for the PHP manual on the PHP site. Typing json into that would have got you to http://php.net/json_encode. If that can't natively handle your variable type then you'll need to massage the data into simple types first. Stuart I have RTFM, I was hoping that someone had an example handy. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting an unordered list into JSON
On 5 Mar 2012, at 15:50, Jay Blanchard wrote: > I am off on my next tangent now and I have not really thought about this too > much yet but have you seen a method to convert a nested unordered list into > JSON using PHP? There's a very useful search function for the PHP manual on the PHP site. Typing json into that would have got you to http://php.net/json_encode. If that can't natively handle your variable type then you'll need to massage the data into simple types first. -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
[PHP] Converting an unordered list into JSON
Good morning PHP groupies! I am off on my next tangent now and I have not really thought about this too much yet but have you seen a method to convert a nested unordered list into JSON using PHP? Thanks! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php