Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从“中提取值”;字符串数组";在php中_Php - Fatal编程技术网

从“中提取值”;字符串数组";在php中

从“中提取值”;字符串数组";在php中,php,Php,在我的'abc'表中有一个名为'details'的列。此列是具有不同值的字符串。 例如:- 现在我只需要每列的颜色值。如何仅提取此特定值。 所有行的颜色值都不同。您可以使用下面的代码执行此操作 $details = "( [Fruit : Mango][Vegetable : Potato][Color : Red] )"; echo str_replace('] )','',trim(str_replace(': ','',strrchr( $details, ': ' )))); 我的错,

在我的
'abc'
表中有一个名为
'details'
的列。此列是具有不同值的字符串。 例如:-

现在我只需要每列的颜色值。如何仅提取此特定值。
所有行的颜色值都不同。

您可以使用下面的代码执行此操作

$details = "( [Fruit : Mango][Vegetable : Potato][Color : Red] )";
echo str_replace('] )','',trim(str_replace(': ','',strrchr( $details, ': ' ))));
我的错,试试这个

$color=substr(details[0], strrpos(details[0], ":"),strlen ( details[0] ));

这个表是数组吗?@ShikharSubedi OP说
这个列是一个具有不同值的字符串@Salik well这不是一个数组dude..显示abc表的结构。表不是数组。该表中的一列是字符的组合。这一切加在一起@萨利克:没有详细信息[0][2]会给我“水果”的“r”。@Rinku我知道你提到了它的字符串,这就是我为什么使用
str
funtions@Rinku萨利克回答给你
r
,因为你通过做[0][2]它将给出字符串中的第三个值,即
r
,准确地说,下面是详细信息列的值之一。[ID:62367][s版本:6.0.3][OVersion:12.1.0.1][Platform:SOLARIS][OS:11]。我只需要整个字符串中的Oversion值,我真正需要的是abc表的details列的每一行中的Oversion值。
$color=substr(details[0], strrpos(details[0], ":"),strlen ( details[0] ));