Q:

PHP - Adding echo statement into a link array

I'm trying to modify a link array in php to add a variable at the end of a link. I thought this was a very easy thing to do, but I keep erroring out when I do it. I'm not sure if I am missing syntax or if it is not possible to do it the way I am doing it.
Here is the array without any modifications and it works fine
$links[]=array(
"url"=>'?p=worksheet', // this is one way I tried, I also added ''
'name'=>'Worksheet',   // This is where the name I want displayed goes
'order'=>999999,
);
}

The variable I am trying to add is $cust_id
This is how I am trying to add it:
$links[]=array(
"url"=>'?p=worksheet'<?php echo $cust_id ;?>, // this is one way I tried, I also added ''
'name'=>'Worksheet',   
'order'=>999999,
);
}

A:

echo does output at the moment you call it. You're trying to concatenate two strings. And you also cannot embed PHP code within PHP code. Try
'url' => '?p=worksheet' . $cust_id,
                       ^^^^^^^^^^^

instead.

