i use curl method post , receive response sms aggregator.
$url = "https://www.smsgatewaycenter.com/library/send_sms_2.php?".$request; $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); list ($status, $returnmobileno, $statusdetails) = split('\|', $curl_scraped_page);
now aggregator gives response in single when send single sms this
$curl_scraped_page = "success | 919********** | 659613958369444158-117942947553648183"; //this example
so use list function unique id 659613958369444158
before hyphen. until single response when response under, not able first unique id response.
multiline response
success | 917*********| 3287615453600499019-106346209426268709 success | 919********* | 3287615453600499019-483762398162272572 success | 9196********** | 3287615453600499019-204615952244351373
or single line multi response
success | 917*********| 3287615453600499019-106346209426268709 success | 919********* | 3287615453600499019-483762398162272572 success | 9196********** | 3287615453600499019-204615952244351373
from above given multi-line or single line multi response. need catch success/error
, 3287615453600499019
, store in db.
somehow lost preg_match()
.
how should able achieve it?, gave after trying 3 hours , seeking here.
/(\d+)-/
should work fine put desired number capture group:
<?php $str = "success | 917*********| 3287615453600499019-106346209426268709 success | 919********* | 3287615453600499019-483762398162272572 success | "; if (preg_match("/(success|error) \|.*?\| (\d+)-(\d+)/", $str, $matches)) { echo "$matches[1] - $matches[2]"; } else { // no match }
output:
3287615453600499019
Comments
Post a Comment