Hello again 🙂
I need some advice / assistance again please.
I am working with SOAP and i can successfully get the results to a query i run, so this is not related to SOAP but rather to the results returned and how to match specific results.
I have an array, that looks like this (just an example array based on the returned SOAP results):
Array
(
[49] => Carrier 1 - INBOUND (1-8666)
)
The above array is referenced by : $assignno1->didID = $dids1; (as seen below, in the code)
I want to match a specific string, like 1-8888 and then return the ID of the rows matched (found inside the []). You will notice that the above array contains 1-8666, which is not what I want to match. the problem I am having is that I am unable to perform the search and match, so I am actually matching the 1-8666 number, even though I do not want to.
In other words, I DON'T WANT TO MATCH the above, but I seem to be matching it and that is not what I want. Clearly something is wrong with my preg_match and the results returned.
If I do not match, I do not want anything returned. Only if I match, do I want it to return results.
Here is some example code for the above, that is not working.
$numbertomatch = 2; //The amount of numbers I want to match and then assign
$ext_id = new stdClass();
$ext_id->userID = $result->ID;
$public_no1 = $client->GetPublicNoPoll($ext_id);
$dids1 = array();
if (!is_soap_fault($public_no1)) {
if (isset($public_no1->publicNo->available)) {
if (is_object($public_no1->publicNo->available)) {
$_dids1 = new stdClass();
$_dids1 = $public_no1->publicNo->available;
$dids1[$_dids1->ID] = $_dids1->channel.' ('.$_dids1->externalNo.')';
$i = (int)1;
foreach ($public_no1->publicNo->available as $key => $val)
if (preg_match("/^1-8888/", $val->externalNo)) {
$dids1[] = $val->ID;
if ($i == (int)$numbertomatch)
{
break;
}
else
{
$i++;
}
}
}
}
}
$assignno1 = new stdClass();
$assignno1->didID = array();
$assignno1->didID = $dids1;
$assignno1->userID = $result->ID;
$assignnoresult1 = $client->AssignPublicNo($assignno1);
$didNumberCount = count($assignno1->didID);
I suspect that my problems are the foreach and the preg_match, so if someone is good with this sort of thing, please can you give me a hand.
I can successfully get a list of numbers and i can also successfully assign numbers. Both are done by SOAP.
My problem is the matching and returning the matched results.
Thanks in advance.