Hello,

`
$url='https://xxxxxx='.$data;
$contents = file_get_contents($url);
$json_data = json_decode($contents);


$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


$res = curl_exec($ch);
$customers[] = $res;

$err = curl_error($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
//echo $contentType;


curl_close($ch);

if ($err) {
  echo "cURL Error #:" . $err;
}

else {
	echo $res;
	`

I post with PHP cURL, a SQL query "SELECT * FROM customers"and I retrieve the following string :
Nom Prenom email
SUXXX JEAN-BAPTISTE xxx@xxx94.com
PINXXX LAURENT xxx@gmail.com
EXCXXX EVELYNE xxx@bbox.fr

How can I extract the data to post them to another remote server ?
How can I fetch the data in json ?
How can I convert this string in a associative array ?

Thank you in adance

    1) that looks something like CSV but with some sort of whitespace (tabs) for separators. See if str_getcsv will work for you.
    2) That depends on whether the server you're requesting the data from will do that.
    3) See (1).

      I would like to learn this tactic. Thanks for your updates.

        Write a Reply...