Key & Value Arrays
$MyKeyValueArray = array(
'comments' => $comments_count,
'responses' => $responses_count
);
//Alternative method to create the same an array:
$MyKeyValueArray = [
'comments' => $comments_count,
'responses' => $responses_count
];
or create like this
$MyKeyValueArray = array();
$MyKeyValueArray['comments'] = $comments_count;
$MyKeyValueArray['responses'] = $responses_count;
Accessing array keys and values
foreach ($MyKeyValueArray as $Key => $Value)
{
echo "{$Key} => {$Value} ";
}
foreach ($MyArray as $Item)
{
}
Remove Array Value
unset($MyArray["My index name"]);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.