亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何截斷字符串,或從 php 中的字符串中提取部分值

如何截斷字符串,或從 php 中的字符串中提取部分值

PHP
青春有我 2023-06-18 17:48:04
你好,我有值 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


查看完整回答
反對 回復 2023-06-18
  • 1 回答
  • 0 關注
  • 147 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號