How to pass array data in a url?

Hi All,

I would like to pass my array data into a url:

this is the array data:

array(‘dealPayments/buy’, ‘dealid’ => $model->id),

Which I would like to pass into a <a> so when someone clicks and image it gets send to the url set by the array data.

I tried this:

echo CHtml::link(

but it is unfortunately echoing the <a> tag inside my href, I only need the url with the arrway data at the end , how to do this please?

Thank you,


You can use createUrl or createAbsoluteUrl

Yii::app()->createAbsoluteUrl('controller/action', array('lang' => 'en'));

You can put a link on an image like this:

echo CHtml::link(CHtml::image(Yii::app()->baseUrl . '/images/myimage.gif'), array('controller/action'));

Thank you Moginn,

Is it the same for both Yii 1 and Yii 2 please?

Thank you,


In Yii 2 to create a link you should use Html::a

to create an image you should use Html::img

to create url you should use Url

Thank you so much!

The last link you gave me is a bit of a gold mine (: thats exactly what I was looking for!