Q:

Javascript function in PHP?

I have a function that is in PHP that I need to use in my Javascript program... how would I go about doing so? The javascript function takes in a name, and returns an array derived from that name. I'm going to assume that I'll have to make the name into a json object (and edit the php function so that it also returns it as a json object). Is there any way to do this? Thanks.
There's basically this function written in javascript, let's say getData, which is written in javascript. It is used like var fizz = getData(bar). I have a php program that needs to be able to input the bar as well as get the returning fizz.

A:

you can do it like so:
<script type="text/javascript">
   var php_func_result = <?=json_encode(my_function($my_param)); ?>;
</script>

