Reputation: 121
$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
}
Upvotes: 0
Views: 40
Reputation: 618
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
Upvotes: 1