Regarding Arrays - when it's not a number

Display a human-readable label instead of a filename in a CF dropdown.

Overview

The issue occurs because string keys in PHP arrays must be quoted, unlike numeric keys.
Quote the filename string key in the array definition to correctly map it to the desired display label.

Answered
de designsedge 03 Jun, 2015
Answer
So, I have a problem that I can't get my head around. I am using the array function (PHP) based on your colors guide.
When I am using numbers 1=green, 2=blue, etc. it works - brilliantly, the output is the human readable response.

The problem I have is that my next drop-down-select is a file. filename.mp3 = Formal File Name. When I try the same code using the names, it still displays filename.mp3.

The code inside the array looks like this:
overload.mp3 => 'Overload',
I have triple checked the variables and code and they are identical, what am I doing wrong?

Again, thanks so much for a great product, it is helping my foray into coding and a great way to learn!
Mike

PS - this is the guide I am using
Gr GreyHead 03 Jun, 2015
1 Likes
Hi Mike,

In PHP strings need to be quoted, integers don't. Please try
'overload.mp3' => 'Overload',

Bob
de designsedge 03 Jun, 2015
Bob -

Perfection, figured it was something like that, but afraid to use a ' or a , or a ; (afraid PHP would catch the server on fire!)

Thanks so much!
This topic is locked and no more replies can be posted.