Answer the question
In order to leave comments, you need to log in
How to output php array correctly?
There is an array.
There is an index.php file, into which the data from the array is pulled.
How can I make it so that somewhere in this file I specify 1 time a key, such as "stul", so that when I call it, write predmet. Thus, if there are a lot of index.php files and in the file itself a call from an array is used a lot, I would indicate this key at the beginning of the file and that's it.
Answer the question
In order to leave comments, you need to log in
Instead of separate arrays for each item, create a single array:
$items = [
'school_table' => [
'name' => 'School Table',
'price' => 100
],
'school_chair' => [
'name' => 'School Chair',
'price' => 50
]
];
$item = $items[ 'school_table'];
echo $item['name'] . ' for ' . $item['price'] . ' money';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question