I have the following Array:
Array
(
[0] => 32
[1] => Array
(
[uuid] => 92bbf05c-b49e-4950-9d4a-69c226325131
[conversation_uuid] => CON-ee2287cb-ddb7-47e3-9595-0b4d36ac57e3
[status] => failed
[direction] => outbound
)
)
And wish to get the id and the status, I have the following code:
<?php
require __DIR__ . '/../env.php';
//TransferLog Tropo
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
header('Content-Type: application/json');
$body = file_get_contents('callnexmo.log');
//$body = json_decode($json, true);
//$id=$_GET['id'];
//$body=array($id, $json);
//$req_dump = print_r($body, true );
//$fp = file_put_contents('callnexmo.log', $req_dump);
$conn = new mysqli($servername, $username, $password, $database);
//foreach ($body as $value)
//{
$status=$body[1]['status'];
$to=$body[1]['to'];
$from=$body[1]['from'];
$id=$body[0];
echo " body = $body";
var_dump($body);
echo " status = $status";
var_dump($status);
echo " id = $id";
var_dump($id);
//rest of the code
But the output gets me
Warning: Illegal string offset 'status' in /opt/lampp/htdocs/buttoncall/skeleton-application/ficheiros/records/teste.php on line 23
Warning: Illegal string offset 'to' in /opt/lampp/htdocs/buttoncall/skeleton-application/ficheiros/records/teste.php on line 24
Warning: Illegal string offset 'from' in /opt/lampp/htdocs/buttoncall/skeleton-application/ficheiros/records/teste.php on line 25
body = Array
(
[0] => 32
[1] => Array
(
[uuid] => 92bbf05c-b49e-4950-9d4a-69c226325131
[conversation_uuid] => CON-ee2287cb-ddb7-47e3-9595-0b4d36ac57e3
[status] => failed
[direction] => outbound
)
)
string(264) "Array
(
[0] => 32
[1] => Array
(
[uuid] => 92bbf05c-b49e-4950-9d4a-69c226325131
[conversation_uuid] => CON-ee2287cb-ddb7-47e3-9595-0b4d36ac57e3
[status] => failed
[direction] => outbound
)
)
"
status = rstring(1) "r"
id = Astring(1) "A"
I have been doing logic similar to this one, and it has work, but now I can seem to put my finger in the errror.. Can some one help me?