打破PHP串联成独立实体 [英] Break Concatenation Into Seperate Entities in PHP

查看:173
本文介绍了打破PHP串联成独立实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库查询,返回一个连接字符串的在希伯莱语以这种形式(编码UTF-8。如果该事项)

布拉布拉,foofoo,BARBAR

我想借此连接字符串,并把它分解成一个新的PHP阵列的不同成员。所以,我将结束:

  $ NewArray = [
    1=> 布拉布拉
    2=> foofoo
    3=> BARBAR
];


解决方案

  $字符串=布拉布拉,foofoo,BARBAR
$ ARR =爆炸(,,$字符串);
的print_r($ ARR);

您可以通过使用PHP的爆炸()实现这个功能。

I've got a DB query that returns a concatenated string In The Hebrew Language (Encoding UTF-8 If that matters) in this form:

blabla,foofoo,barbar

I would like to take this concatenated string and break it down into different members of a new PHP array. So, I will end up with:

$NewArray = [
    "1" => "blabla",
    "2" => "foofoo",
    "3" => "barbar"
];

解决方案

$string = "blabla,foofoo,barbar";
$arr = explode(",",$string);
print_r($arr);

You can achieve this by using php explode() function.

这篇关于打破PHP串联成独立实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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