如何在PHP中将字符串转换为数组 [英] how to convert a string to an array in php

查看:99
本文介绍了如何在PHP中将字符串转换为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在php中转换数组中的字符串,即

how to convert a string in array in php i.e

 $str="this is string";

应该是这样

 arr[0]=this
      arr[1]=is
      arr[2]=string 

str_split($str, 3);

将字符串拆分为3个字符的单词,但我想在数组中的空格后转换字符串.

split the string in 3 character word but i want to convert the string after whitespace in an array.

推荐答案

$array = explode(' ', $string);

这篇关于如何在PHP中将字符串转换为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆