当前位置:Gxlcms > PHP教程 > PHP数组转字符串与PHP字符串转数组的相关方法解析_PHP教程

PHP数组转字符串与PHP字符串转数组的相关方法解析_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

我们今天为大家介绍的PHP数组转字符串 implode()

  1. php
  2. $vegetables[0] = "corn";
  3. $vegetables[1] = "broccoli";
  4. $vegetables[2] = "zucchini";
  5. $text = implode(",", $vegetables);
  6. echo $text;
  7. ?>

运行结果

corn,broccoli,zucchini

2 PHP字符串转数组 explode()

  1. php
  2. $text = "corn, broccoli, zucchini";
  3. $vegetables = explode(", ", $text);
  4. print_r($vegetables);
  5. ?>

运行结果:

  1. Array
  2. (
  3. [0] => corn
  4. [1] => broccoli
  5. [2] => zucchini
  6. )

以上两段代码就是我们向大家介绍的关于PHP数组转字符串和PHP字符串转数组的相关代码。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446366.htmlTechArticle我们今天为大家介绍的 PHP数组转字符串 implode() ? php $vegetables[0]="corn"; $vegetables[1]="broccoli"; $vegetables[2]="zucchini"; $ text = implode (",",$vegetables)...

人气教程排行