新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
PHP數(shù)組轉(zhuǎn)字符串與PHP字符串轉(zhuǎn)數(shù)組的相關(guān)方法解析
我們今天為大家介紹的PHP數(shù)組轉(zhuǎn)字符串與PHP字符串轉(zhuǎn)數(shù)組的代碼將會(huì)用到函數(shù)implode() 和函數(shù)explode() 。其中implode() 函數(shù)是用來(lái)數(shù)組轉(zhuǎn)字符串時(shí)用,而explode() 函數(shù)則是用來(lái)處理字符串轉(zhuǎn)數(shù)組的。

#t#PHP數(shù)組轉(zhuǎn)字符串 implode()
- $vegetables[0] = "corn";
- $vegetables[1] = "broccoli";
- $vegetables[2] = "zucchini";
- $text = implode(",", $vegetables);
- echo $text;
- ?>
運(yùn)行結(jié)果
corn,broccoli,zucchini
2 PHP字符串轉(zhuǎn)數(shù)組 explode()
- $text = "corn, broccoli, zucchini";
- $vegetables = explode(", ", $text);
- print_r($vegetables);
- ?>
運(yùn)行結(jié)果:
- Array
- (
- [0] => corn
- [1] => broccoli
- [2] => zucchini
- )
以上兩段代碼就是我們向大家介紹的關(guān)于PHP數(shù)組轉(zhuǎn)字符串和PHP字符串轉(zhuǎn)數(shù)組的相關(guān)代碼。
分享標(biāo)題:PHP數(shù)組轉(zhuǎn)字符串與PHP字符串轉(zhuǎn)數(shù)組的相關(guān)方法解析
轉(zhuǎn)載來(lái)源:http://m.5511xx.com/article/copdpoh.html


咨詢
建站咨詢
