从下面的html内容中,我试图用php脚本获取javascript数组变量" aDataSet"的内容。我相信我可以使用正则表达式,但到目前为止我还没有能够导出数据。
最好的方法是什么? html内容加载到php变量中。理想情况下,我想在php数组中获取信息?
有什么想法吗?
谢谢
<html>
<head>
</head>
<body>
<!-- html code -->
<script type="text/javascript">
var imgShowBtn = '<img src="templates/medias/search.png" title="See form" />';
var imgEditBtn = '<img src="templates/medias/update.png" title="Modify the complaint" />';
var imgPdfBtn = '<img src="templates/medias/pdf.jpg" title="See report" />';
jQuery.fn.dataTableExt.oSort['date-case-asc'] = TriDateFrAsc;
jQuery.fn.dataTableExt.oSort['date-case-desc'] = TriDateFrDesc;
var aDataSet = [
[" ","1202 26a", "02/29/2012", "01/17/2012", "akdslj91", "345910K30", "Berlin 800905", "4" ],
[" ","1202 152", "02/29/2012", "01/17/2012", "ahkqos12", "134711223", "qwerty 5493", "4" ],
[" ","1202 241", "02/29/2012", "01/13/2012", "ahkqos12", "345910130", "azerty 1020090951", "4" ],
[" ","1202 222", "02/29/2012", "01/31/2012", "askj192a", "136411208", "paris 1020090520", "4" ] ];
</script>
<!-- html code -->
</body>
</html>
答案 0 :(得分:0)
您的用例并不完全详细,但也许您也可以使用PHP json_decode
函数,它接受表示Javscript对象的字符串:
实施例
<?php
$strDataset = '[ [" ","1202 26a", "02/29/2012", "01/17/2012", "akdslj91", "345910K30", "Berlin 800905", "4" ], [" ","1202 152", "02/29/2012", "01/17/2012", "ahkqos12", "134711223", "qwerty 5493", "4" ], [" ","1202 241", "02/29/2012", "01/13/2012", "ahkqos12", "345910130", "azerty 1020090951", "4" ], [" ","1202 222", "02/29/2012", "01/31/2012", "askj192a", "136411208", "paris 1020090520", "4" ] ]';
var_dump(json_decode($strDataset));
的输出代码