0

My code in php is

echo $preference[0]."</br>";
echo '<p class="filter_entity">'.$preference[0].'<img src="' . base_url() . 'images/close-icon.png" onClick="filter_close()"></p>';

html out put is

Business
<img onclick="filter_close()" src="http://localhost/AEC/images/close-icon.png">

I want to put $preference[0] in filter_close() of my php code ... dont know how to do it .

2
  • 4
    onClick="filter_close('.$preference[0].') like this?? Commented Feb 9, 2015 at 12:11
  • Are you sure it is html output of this code ? Commented Feb 9, 2015 at 12:15

2 Answers 2

1

Something like this?

$param = $preference[0];
echo '<p class="filter_entity">'.$preference[0].'<img src="' . base_url() . 'images/close-icon.png" onClick="filter_close(\''.echo $param.'\')"></p>';

Just append the variable as a parameter of the js function

Sign up to request clarification or add additional context in comments.

2 Comments

What do you want to pass to a php variable?
i did it like this ,,, your solution worked onClick="filter_close(\''.$filter_name.'\',\''.$preference[2].'\')"
0

http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double

echo "Some array item: {$array[0]}";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.