ExternalInterface/Javascript

I have a little problem that I’ve spent hours trying to figure out. I am trying to return an array from javascript. The problem (I assume) is that is has some php in the javascript function

Here is the code I am trying that doesnt work:
JavaScript:
<script type=“text/javascript”>
function JavaFunc(){
<?php
$company_name[0] = “Kirupa”;
echo ‘var company_name = new Array();’;
echo ‘company_name[0] = ‘.$company_name[0].’;’;
echo ‘return company_name;’;
?>

        }

</script>

AS3
var theArray = ExternalInterface.call(“JavaFunc”);
theTextField.text = theArray[0]

if I change the javascript code to…

<script type=“text/javascript”>
function JavaFunc(){
<?php
echo ‘var company_name = new Array();’;
echo ‘company_name[0] = “Kirupa”;’;
echo ‘return company_name;’;
?>

        }

</script>
The textfield text is the first element of the array as it should. There must be something wrong with the way I’m echoing out the java from php. If anyone can help me understand what I’m doing wrong I would greatly appreciate it.