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

#t#PHP數(shù)組轉字符串 implode()
- $vegetables[0] = "corn";
- $vegetables[1] = "broccoli";
- $vegetables[2] = "zucchini";
- $text = implode(",", $vegetables);
- echo $text;
- ?>
運行結果
corn,broccoli,zucchini
2 PHP字符串轉數(shù)組 explode()
- $text = "corn, broccoli, zucchini";
- $vegetables = explode(", ", $text);
- print_r($vegetables);
- ?>
運行結果:
- Array
- (
- [0] => corn
- [1] => broccoli
- [2] => zucchini
- )
以上兩段代碼就是我們向大家介紹的關于PHP數(shù)組轉字符串和PHP字符串轉數(shù)組的相關代碼。
新聞名稱:PHP數(shù)組轉字符串與PHP字符串轉數(shù)組的相關方法解析
鏈接URL:http://www.fisionsoft.com.cn/article/copdpoh.html


咨詢
建站咨詢
