0

have an column named 'details' in my 'abc' table. This column is a string with different values . eg:-

details[0]=( [Fruit : Mango][Vegetable : Potato][Color : Red] )
details[0]=( [Fruit : Apple][Vegetable : Brinjal][Color : Blue] )

Now i want only the Color Value from every column. How do i extract only this specific value. All rows have different values for the Color.

4

2 回答 2

0

我的错,试试这个

$color=substr(details[0], strrpos(details[0], ":"),strlen ( details[0] ));
于 2013-09-06T05:19:49.703 回答
0

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

$details = "( [Fruit : Mango][Vegetable : Potato][Color : Red] )";
echo str_replace('] )','',trim(str_replace(': ','',strrchr( $details, ': ' ))));

PHP 小提琴演示

于 2013-09-06T04:50:03.540 回答