In terms of my data structure, I have an array of communications, with each communications_id itself containing three pieces of information: id, score, and content.
You can have a look to array_walk_recursive function . This is a working snippet of creating of recursive array to string conversion :
$array =
array(
"1" => "PHP code tester Sandbox Online",
"foo" => "bar",
5 ,
5 => 89009,
"case" => "Random Stuff",
"test" =>
array(
"test" => "test221",
"test2" => "testitem"
),
"PHP Version" => phpversion()
);
$string="";
$callback =
function ($value, $key) use (&$string) {
$string .= $key . " = " . $value . "\n";
};
array_walk_recursive($array, $callback);
echo $string;
## 1 = PHP code tester Sandbox Online
## foo = bar
## 2 = 5
## 5 = 89009
## case = Random Stuff
## test = test221
## test2 = testitem
## PHP Version = 7.1.3