這是我用來從 MYSQL 返回的數(shù)據(jù)在 PHP 中創(chuàng)建數(shù)組的代碼:-foreach($empRecords->result_array() as $row) { $tid = $row['transaction_id']; $checkbox = '<input type="checkbox" name="check[]" value="'.$tid.'">'; $data[] = array( $checkbox, $row['transaction_id'], $row['member_id'], $row['member_name'], ); }我得到的結果是:-Array( [0] => Array ( [0] => <input type="checkbox" class="CheckedarrayCount" name="check[]" value="247"> [1] => 247 [2] => 101257 [3] => Nithin ) [1] => Array ( [0] => <input type="checkbox" class="CheckedarrayCount" name="check[]" value="249"> [1] => 249 [2] => 101258 [3] => Rekha ))但這就是我得到的結果:-{ "data": [ ["\u003Cinput type=\"checkbox\" class=\"CheckedarrayCount\" name=\"check[]\" value=\"247\"\u003E", "247", "101257", Nithin\u003C\/a\u003E", ], ["\u003Cinput type=\"checkbox\" class=\"CheckedarrayCount\" name=\"check[]\" value=\"249\"\u003E", "249", "101258", "ERekha\u003C\/a\u003E"],}請幫忙!
1 回答

尚方寶劍之說
TA貢獻1788條經(jīng)驗 獲得超4個贊
創(chuàng)建數(shù)組時,您應該在PHP中對 html 字符進行編碼
使用htmlspecialchars
$checkbox?=?htmlspecialchars('<input?type="checkbox"?name="check[]"?value="'.$tid.'">',?ENT_QUOTES);
或使用htmlentities
$checkbox?=?htmlentities('<input?type="checkbox"?name="check[]"?value="'.$tid.'">');
如果你想在解析返回的字符串時使用Javascript
<script> //?console.log(decodeURIComponent(YOUR_STRING)) console.log(decodeURIComponent('\u003c')); </script>
- 1 回答
- 0 關注
- 92 瀏覽
添加回答
舉報
0/150
提交
取消