Defining a variable in an associative array

Hi,

I’ve been wracking my brain on this one but there is probably a simple solution. I want to define a variable, and pass it into and array. For example below I want the contact id to be something like $contactID. Is this possible, and if not how do I get a dynamic value in that array? Thank you!

array(
‘id’ => uniqid(),
‘method’ => ‘getLastVisit’,
‘jsonrpc’ => ‘2.0’,
‘params’ => array(
‘contact_id’ => 305707747,
‘contact_segment_id’ => 227894,
)

Where the numbers currently are, just needs to be the variable or function that retrieves that value.

‘params’ to me tells me this would be a great place to use a database table.

[php]$query_params = “…MYSQL Paramaters…”;[/php]

[php]
$dynamicValue = [“contact_id” => “88888”, “contact_segment_id” => 90902 ];

$finalArray = [
‘id’ => uniqid(), //a way to get values into an array with a function
‘method’ => ‘getLastVisit’,
‘jsonrpc’ => ‘2.0’,
‘params’ => $dynamicValue
];

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service