Answer the question
In order to leave comments, you need to log in
Convert string to array in php?
Good afternoon!
In general, there is the following line: name=%D0%98%D0%BB%D1%8C%D1%8F;phone=89213251626
You need to get an array of the form in php:
$array["name"] = "%D0%98%D0%BB%D1%8C%D1%8F";
$array["phone"] = "89213251626";
I do it in order to eventually decode the name to the output (url decode) :)
Answer the question
In order to leave comments, you need to log in
$arr = explode(';', 'name=%D0%98%D0%BB%D1%8C%D1%8F;phone=89213251626');
foreach($arr as $item) {
$tmp = explode('=', $item);
$array[$tmp[0]] = $tmp[1];
}
$arr = null;
$returnValue = parse_str('name=%D0%98%D0%BB%D1%8C%D1%8F&phone=89213251626', $arr);
//результат
array (
'name' => 'Илья',
'phone' => '89213251626',
)
$result = array();
$stringParams = 'name=%D0%98%D0%BB%D1%8C%D1%8F;phone=89213251626';
$paramsArray = explode(';', $stringParams);
foreach ($paramsArray as $item) {
list($k, $v) = explode('=', $item);
$result[$k] = $v;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question