2

I want to use $par_id = '31512071'; variable in PHP array(); function.

I tried using "par_id" => $par_id instead of "par_id" => 31512071 in the following php code, but it didn't work. How can i use the variable inside array(); method?

$par_id = '31512071';

$params = array(
   "parcelNum" => "315-12-071",
   "b_2" => "Search",
   "opts"=>"2",
   "txtPageSize" => 10,
   "par_id" => 31512071
);
1
  • What do you mean by it didn't work? Did you dump the variable with var_dump() to determine if the variable was correctly parsed or not? Commented Mar 19, 2015 at 20:01

1 Answer 1

2

You can do:

$par_id = '31512071';

$params = array(
   "parcelNum" => "315-12-071",
   "b_2" => "Search",
   "opts"=>"2",
   "txtPageSize" => 10,
   "par_id" => "{$par_id}"
);
Sign up to request clarification or add additional context in comments.

1 Comment

Actually it's the same as "par_id" => $par_id

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.