I have a string variable like following
$str= '[[["how ","no use","",""],["to ","no use","",""],["solve this","no use","",""]]]';
And i want some parts of this string to make another one like following
$result="how to solve this";
Is it possible to create $result from $str?
Am new to php someone help me to solve this or any idea to solve this.
since the string is json, you can use json_decode
to turn that string into an array. Since the whole thing is wrapped in []
, reset
is used to shear off the out outer array.
$string= '[[["how ","no use","",""],["to ","no use","",""],["solve this","no use","",""]]]';
$result = '';
foreach(reset(json_decode($string)) as $piece)
{
$result .= reset($piece);
}
echo $result;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments