I have a language system written in PHP. It loads phrases from the database to the array and then displays some of them during the page render. Right now it looks simple:
<h1><?=$phrase['phrase_callsign']?></h1>
What I need is to know, what particular keys was used during the page rendering procedure.
I have a special function to count and log phrases, so code looks like this:
<h1><?=$this->model->phrase('phrase_callsign')?></h1>
What I'm asking for, is there are something already built in in PHP instead of the handwritten function to display array keys used? Personally I haven't found anything yet.
Thanks.
If I understand correctly you want to record the keys you are using to retrieve callsigns from the array. I would just define a regular function where you pass in the callsign. It adds it to another array, logs it, and then return the callsign value.
function getCallsign($callsign) {
// log callsign
array_push($callsigns, $callsign);
return $phrase[$callsign];
}
If you want to make a list of all the callsigns that were displayed, just push them onto a variable:
<h1><?php $all_callsigns[] = $phrase['phrase_callsign']; echo $phrase['phrase_callsign']; ?></h1>