Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
你可以这样做:
$arr = explode('=>',$str); $arr = explode(')',$arr[1]); echo "Value = ".$arr[0]; // prints: Value = abc123hfj
或者使用正则表达式你可以这样做:
$str = 'asns([this_is_key]=>abc123hfj)'; if(preg_match('/=>([^)]*)\)/',$str,$matches)) { echo "Value = ".$matches[1]; // prints: Value = abc123hfj }
如果你想只使用一次爆炸,你可以这样做:
$arr = explode('=>',chop($str,')')); echo "Value = ".$arr[1]; // prints: Value = abc123hfj
You can do:
or using regex you can do:
If you want to use explode just once you can do:
如果你的目标是获得数组(1 =>“值”,2=> “哪个内容编号和字母”);
您可以只搜索第一次出现的空格,然后调用两个 substr 函数。或者
$string = 'value which content number and alphabates'; $result = array(substr($string, 0, strpos($string, ' ')), substr($string, strpos($string, ' ')+1)); print_r($result);
你可以在取消数组键 0 后进行爆炸并内爆爆炸数组,就像这样
$string = 'value which content number and alphabates'; $chunk = explode(' ', $string); $result = array(); $result[] = $chunk[0]; unset($chunk[0]); $result[] = implode(' ', $chunk); print_r($result);
或者如果你想从字符串中获取部分“值”,只需使用列表
$string = 'value which content number and alphabates'; list($result) = explode(' ', $string); echo $result;
If your goal is to get array(1 => "value",2 => "which content number and alphabates");
You can just search first occurrence of a whitespace, and call two substr functions. Something like that
Or you can do explode and and implode exploded array, after unsetting array key 0, like so
Or if you want to get just part "value" from your string, just use list
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
你可以这样做:
或者使用正则表达式你可以这样做:
如果你想只使用一次爆炸,你可以这样做:
You can do:
or using regex you can do:
If you want to use explode just once you can do:
如果你的目标是获得数组
(1 =>“值”,
2=> “哪个内容编号和字母”);
您可以只搜索第一次出现的空格,然后调用两个 substr 函数。或者
你可以在取消数组键 0 后进行爆炸并内爆爆炸数组,就像这样
或者如果你想从字符串中获取部分“值”,只需使用列表
If your goal is to get array
(1 => "value",
2 => "which content number and alphabates");
You can just search first occurrence of a whitespace, and call two substr functions. Something like that
Or you can do explode and and implode exploded array, after unsetting array key 0, like so
Or if you want to get just part "value" from your string, just use list