'Output values inside the array

$stock = [
    "marketplace" => [
       "stocks" => 'if($a = 1) {return 6}'
    ]
];

How to use the code inside the array value ?

return $stock['marketplace']['stocks'];

I plan to get in the method

if($a = 1) {
  return 6
}
php


Solution 1:[1]

If you want to execute the code, you can do:

eval($stock['marketplace']['stocks']);

but as @nice_dev said it is not recommended to use eval

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tenshi