$ar = array(
'cap1' => '12',
'cap2' => '14',
'cap3' => '244',
'cap4' => '556',
'cap5' => '53',
);
foreach($ar as $key=>$val) {
echo $key, $val ; }
echo $ar[cap1];
<?php
$ar = array(
'cap1' => '12',
'cap2' => '14',
'cap3' => '244',
'cap4' => '556',
'cap5' => '53',
);
$rnd = "cap".random_int(1, count($ar));
echo $ar[$rnd];