ohad Posted December 27, 2020 Share Posted December 27, 2020 Hi All, I have a question regarding arrays I get a data from a field in Oracle DB into a variable: This is the procedure i run: $Param_String=DBOracle::getInstance()->get_job_params($seq); and this is what $Param_string stores after: (string) "Id"=>"1" Then I run this command $parameters=array($Param_String); Now, $Parameters is like this: array(1) ( [0] => (string) "Id"=>"1" ) If i write the code that way: $id='"1"'; $parameters=array("id" => $id); Then, $Parameters is like this: array(1) ( [id] => (string) "1" ) My problem: I want $Parameters to be like the last option when I get the data from the database. The string in the DB (like "Id"=>"1") can be list of such pairs seperated by comma (,). for example ("Id"=>"1", "param2"=>"test_val", "param3"=>"test_val2"...) How can I do that? Quote Link to comment https://forums.phpfreaks.com/topic/311934-question-regarding-arrays/ Share on other sites More sharing options...
Barand Posted December 27, 2020 Share Posted December 27, 2020 58 minutes ago, ohad said: This is the procedure i run: $Param_String=DBOracle::getInstance()->get_job_params($seq); Sounds like you need some code other than that above. If it doesn't produce what you need, don't use it. Find one which will return an array or rewrite that one. Quote Link to comment https://forums.phpfreaks.com/topic/311934-question-regarding-arrays/#findComment-1583469 Share on other sites More sharing options...
NotionCommotion Posted December 27, 2020 Share Posted December 27, 2020 If you are receiving a string such as '"Id"=>"1"'. you are likely requesting the data incorrectly. A hack fix might be to explode('=>', $yourString), but really think you should get to the root of the issue. Any chance they are passing you JSON and it has some helper to make it look more human readable? Quote Link to comment https://forums.phpfreaks.com/topic/311934-question-regarding-arrays/#findComment-1583470 Share on other sites More sharing options...
ohad Posted December 28, 2020 Author Share Posted December 28, 2020 ok Solved it Quote Link to comment https://forums.phpfreaks.com/topic/311934-question-regarding-arrays/#findComment-1583486 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.