将PHP数据注入JavaScript代码[重复]

This question already has an answer here:

What's the preferred way of outputting PHP code within apostrophes? For example this JavaScript code would break and the second line will be totally empty:

var jsString = '<div id="content">'+'<?php echo $something['1'] ?>'+'</div>';

Thanks! I know this is kind of basic and I know how to fix it, but I'm wondering how to do it the right way?

[edit]

I know it looks obvious, but $something["1"] won't work. The same goes for $something[\'1\'].

</div>

This example is working well for me :

<?php
$something['1']='hhhh0';
 ?>
<script type='text/javascript'>
var jsString = '<div id="content">'+'<?php echo $something['1'] ;?>'+'</div>';
    alert(jsString);
</script>