Reputation: 11
How to make a "dictionary" in php which will contain many values for a single key? With single values, I do a class with constants, e.g .:
class Formats {
const big = 1;
const small = 2;
}
and then in the code I use for example:
Formats::big
However, how to do it if I want a given format to contain, for example, dimensions?
In C #, I would do something like this:
static class Formats
{
public static class Big
{
public static int id = 1;
public static int width = 200;
public static int height = 150;
}
public static class Small
{
public static int id = 2;
public static int width = 100;
public static int height = 50;
}
}
and used:
Formats.Big.height;
Thank you in advance :).
Upvotes: 1
Views: 152
Reputation: 3685
What about an array?
class Formats {
const big = array(
"id" => 1,
"width" => 200,
"height" => 150
);
}
Can then access with Formats::big["height"]
Upvotes: 1