我在javascript中有一個數組,用,
分隔。但在他們的內部有一些價值包含,
,因爲它的價值。我的問題是我不想爆炸這些值,但PHP做到了。有什麼辦法來處理它? array[0]='sports, music,videos'
:如何不在PHP中的數組中間爆炸逗號
<form id="form" method="post">
<table>
<tr val="sprots, music, videos"><td>sprots, music, videos</td></tr>
......
......
<tr val="car"><td>car</td></tr>
</table>
<input type="hidden" name="category" id="category" value="">
</form>
<script>
var Data=[];
$('table').find('tr').each(function(){
Data.push($(this).attr('val'));
});
$('#category').val(Data);
</script>
<?php
$category=$_POST['category'];
$tmp=explode(',',$category);
?>
的問題,當它要發生爆炸這樣的值發生。它爆炸爲3分離的數組,這是這樣的: array [0] ='sports',array [1] ='music',array [2] ='videos'。 我想爆炸這個值作爲一個獨特的一部分,我的意思是這樣的: array[0]='sports, music,videos'
秀'的var_dump($類); '從你的代碼 – RomanPerekhrest
你可能需要內爆而不是爆炸.. –
然後不要'爆炸'。或者首先從字符串中刪除你不會被爆炸的東西。 –