简体   繁体   English

PHP拆分从函数返回的值

[英]PHP Splitting up values returned from a function

I have this function I am calling in a class. 我有一个正在上课的函数。 It gets all the phone numbers assigned to a user or company. 它获取分配给用户或公司的所有电话号码。

foreach($obj as $file) {
$clean_number = preg_replace('/[^0-9]/','',$file['matchrule']);
$clean_number = substr($clean_number, 1);
echo $clean_number;
}

It returns all the values and I see them in this function calling the function above: 它返回所有值,我在调用上面的函数的函数中看到它们:

$get_numbers_from_domain = $api->_get_numbers($domain);
echo $get_numbers_from_domain;

So the question is, how do I split the values and treat each phone number returned as separate so that I can input them into another function instead of having a long run on of numbers? 因此,问题是,如何拆分值并将返回的每个电话号码都视为单独的电话,以便我可以将其输入到另一个函数中,而无需长时间使用数字?

The returned value string looks like this: (minus the x's) 返回的值字符串如下所示:(减去x)

8004xxx3048138xxx436 8004xxx3048138xxx436

What I have been trying was something like this with no success by adding a "." 我一直在尝试添加“。”这样的事情,但没有成功。 at the end of my returned numbers. 在我返回的号码末尾。

$NumArray = explode('.', $get_numbers_from_domain);
foreach($NumArray as $num_Array){
    echo $num_Array.'<br>';  
}
$clean_number=array();
foreach($obj as $file) {
$clean_number = preg_replace('/[^0- 9]/','',$file['matchrule']);
$clean_number[]= substr($clean_number, 1);
}
return $clean_number;

So it return the numbers as an array 因此它将数字作为数组返回

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM