你好,我有值 1284&kec=220107&prop=220000這里想取前面的數字& 前面的數字不一定都是三個字母,有時是兩個字母有時也是一個,如何去掉或刪除&后面的值example : 1284&kec=220107&prop=220000result value = 1284example : 11&kec=2332&prop=563454result value = 11你能給個例子嗎?
1 回答

桃花長相依
TA貢獻1860條經驗 獲得超8個贊
您可以使用explode()將 the 轉換string為 an array,然后得到您想要的。像這樣-
$example = '1284&kec=220107&prop=220000';
$ex = explode("&kec", $example); // convert it to array where $kec is found
$value = $ex[0]; // output: 1284 // the first key will hold the value before $kec
$example2 ='11&kec=2332&prop=563454';
$ex = explode("&kec", $example2);
$value = $ex[0]; // output: 11
- 1 回答
- 0 關注
- 147 瀏覽
添加回答
舉報
0/150
提交
取消