Jump to content

Recommended Posts

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?

 

 

Link to comment
https://forums.phpfreaks.com/topic/311934-question-regarding-arrays/
Share on other sites

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.

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.