$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
}
CodePudding user response:
if($a = 1) {
$stocks = 6;
}else{
$stocks = 0;
}
$stock = [
"marketplace" => [
"stocks" => $stocks
]
];
return $stock['marketplace']['stocks'];
CodePudding user response:
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