php - How to get numeric value from cURL array? -


i'm trying fetch numeric value curl response array. unable that. i'm using code

     $urltopost = "http://www.xxxx.yyy.com/zzz.php";      $ch = curl_init ($urltopost);      curl_setopt ($ch, curlopt_post, true);      curl_setopt ($ch, curlopt_postfields, $data);      curl_setopt ($ch, curlopt_returntransfer, true);      $returndata = curl_exec ($ch);      print_r($returndata); 

its prints our new invoice id is: [{-10191}] on page. want fetch 10191 array. tried 1 failed.

     $id = abs(filter_var(implode($returndata), filter_sanitize_number_int)); 

how can retreive numeric value?

if got $returndata string


put after curl_exec:

<?php  $urltopost = "http://www.xxxx.yyy.com/zzz.php"; $ch = curl_init ($urltopost); curl_setopt ($ch, curlopt_post, true); curl_setopt ($ch, curlopt_postfields, $data); curl_setopt ($ch, curlopt_returntransfer, true); $returndata = curl_exec ($ch); //$returndata = 'our new invoice (id) is: [{-10191}]'; preg_match_all("/\{([^\]]*)\}/", $returndata, $matches); $invoiceid = intval(ltrim($matches[1][0], '-')); print_r($invoiceid); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -