字符串分割到PHP​​变量

字符串分割到PHP​​变量

本文介绍了字符串分割到PHP​​变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出洒到以下网址字符串的最佳方式:

basically into the following:

$area = "FFFFFF";
$miles = 100;
$profession = "web developer";

But i've got a brain block and can't really figure out the most efficient way to do it. Any suggestions?

Thanks.

-Edit- I could do with accounting for any missing values, such as:

missing the miles etc.

解决方案
$params = explode('_', $input);
foreach($params as $param) {
    $kv = explode('-', $param);
    ${$kv[0]} = str_replace('+', ' ', $kv[1]);
}

This also account for missing values.

这篇关于字符串分割到PHP​​变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 01:00