severndigital Posted July 24, 2009 Share Posted July 24, 2009 ok .. so i have a url i can access with various get variables to pull information i need. like site.com/?method=search&q=searchstring&option=file the result is echoed on the screen as an array. that looks like this Array ( [0] => Array ( [HANDLE] => Collection-58148 [DISPLAYNAME] => Collection Title ) ) in another script on a completely different sever that DOES NOT have access to the source code of the first script. I am running this $result = file_get_contents('linkwith?all=the&get=information'); how do I get the text output of the array back into an array? I'm not sure what php function (s) to use to do this. Thanks, C Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 24, 2009 Share Posted July 24, 2009 do you have any control over the output of the first server? Quote Link to comment Share on other sites More sharing options...
severndigital Posted July 24, 2009 Author Share Posted July 24, 2009 yes. right now the function that is being called is set to print_r() the array. should I change that? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 24, 2009 Share Posted July 24, 2009 yes, i would recommend using JSON, as it's a more universal format (not PHP specific), but you can also use serialize()/unserialize() or var_export()/eval() JSON: echo json_encode($array); $array = json_decode(file_get_contents('linkwith?all=the&get=information')); Quote Link to comment Share on other sites More sharing options...
severndigital Posted July 24, 2009 Author Share Posted July 24, 2009 ok .. so after a quick look I am using PHP 5.1.6 which does not have Json included. no worries though I installed the PECL extension version of the json functions, since upgrading to 5.2 is not an option at this point. looks like everything is going to work though. Thanks much. -P Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 24, 2009 Share Posted July 24, 2009 you can also get php functions for encoding JSON if you wanted again, another php-specific option is the serialize/unserialize functions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.