阵列由前pressions [英] Array by expressions

查看:118
本文介绍了阵列由前pressions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,我有以下变量,它来自一个网址:

In php I have the following variable which comes from a url:

$data = "data_id=value1/config/value2/config/value3";

它总是进来的格式如下:

It always comes in the following format:


  • data_id =参数的第一个值来

/配置/ - >这是一种参数标签

/ config / -> which is a kind of parameters tab

第二个参数+ /配置/ +等等...

second parameter + / config / + etc ...

我想这些值插入到一个数组,即会发生什么如下:

I want these values ​​to be inserted into an array, i.e., what would happen is the following:


  • 愤怒PHP得到变量 $数据,会赶上第一个参数,在这种情况下,例如值1 (which'll来后 data_id ),并将其插入到数组作为矢量1 ,它需要后不久, /配置/ ,并认识到它是一个分隔符,从而使其采取值2 键,进入阵列,使得循环下去,直到结束。

  • The Wrath php gets the variable $data, would catch the first parameter, in this case e.g. value1 (which'll come after the data_id) and insert it into the array as a vector 1, soon after it takes the / config / and recognizes that it is a separator, thus making it take the value 2 and enter the array, making this loop until the end.

例如:

 $data = "data_id =fish/config/horse/config/car";

该数组将如下所示:

The array will look as follows:

array 
{
    [0] -> fish

    [1] -> horse

    [2] -> Car
}

可能有人帮助我吗?

could someone help me?

推荐答案

假设 data_id 是一个GET变量,你可以做这样的事情。

Assuming data_id is a GET variable, you can do something like this.

$data = $_GET['data_id']

$myArray = explode('/config/', $data);

爆炸()文档

这篇关于阵列由前pressions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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