Trying to create a variable with unique name for each $item.
To prevent error “Only variables can be passed by reference”.
If there are 5 items in array $items, we should get 5 unique variables:
$item_name_1;
$item_name_2;
$item_name_3;
$item_name_4;
$item_name_5;
All of them should be empty.
What is a true solution for this?
You can dynamically create variable names doing the following:
I must warn you though, this is absolutely bad style and I’ve never seen a good reason to use this. In almost every use case an array would be the better solution.