我想在字符串中的數組拆分和值存儲在表中,以陣列的字符串分割 的字符串是如何根據需要ccondition
$string="34=No,46=fgbfb,48=NA,29=NA,45=dsd,49=InConclusive,43=1BHK,35=NA,38=12,39=2,27=q1,41=Others,52=fgfdg,47=fgfg,31=Chawl,33=UpperMiddleClass,37=SelfOwned,30=fdgfdgb,50=fgfdgb,51=fgfdg,32=NA,44=[Refrigerator,Airconditioner]";
我試過爆炸(「」,$串); 但我不想要分割對象陣列,即(44 = [冰箱,空調器])此我要像44和冰箱,空調器
預期結果: -
Array (
[0] => 34=No
[1] => 46=fgbfb
[2] => 48=NA
[3] => 29=NA
[4] => 45=dsd
[5] => 49=InConclusive
[6] => 43=1BHK
[7] => 35=NA
[8] => 38=12
[9] => 39=2
[10] => 27=q1
[11] => 41=Others
[12] => 52=fgfdg
[13] => 47=fgfg
[14] => 31=Chawl
[15] => 33=UpperMiddleClass
[16] => 37=SelfOwned
[17] => 30=fdgfdgb
[18] => 50=fgfdgb
[19] => 51=fgfdg
[20] => 32=NA
[21] => 44=[Refrigerator,Airconditioner]
)
使用另一個分隔符如果您無法控制字符串中的分隔符,可以使用preg_replace('/,(\ d + =)/','XXX $ 1'替換它。使用新分隔符(XXX)代替 –
舉個例子吧 –
不用勺子喂,先試一下 –