如何使用json_encode进行内联事件处理程序?

I am trying to pass a double array to JavaScript and it seems that I need to use json_encode to do so. Most sources show something like this:

<script>
  var array = <?php echo json_encode($array)?>;
</script>

but I can't use script tags in this section of code because the output is only for a small part of the total output page. What is my solution for this?

Here is my output

<?php 

$dataArray = $_POST['array'];
$staged = sizeof($dataArray);

Echo '<table>';
for($r = 0; $r < $staged; $r++){
  $dataArrayString = json_encode($dataArray);
  Echo '<tr>
        <button onclick="removeLineItem("'.$dataArrayString.'", '.$r.')">
            <span class="add-on">
                <i class="glyphicon glyphicon-remove"></i>
            </span>
        </button>';
  for($i = 0; $i < 10; $i++){
    Echo '<td>'.$dataArray[$r][$i];

    Echo '</td>';
  }
  Echo '</tr>';
}
Echo '</table>';