Строка PHP eval() в массив [закрыто] ⇐ Php
-
Anonymous
Строка PHP eval() в массив [закрыто]
This is a strictly personal project, which is why I'm using eval.
The objective is to parse a string from a input form that contains an array, and cast it into an actual array so I can json_encode the result.
$result = @eval('$array = '.$data.';return true;'); example $data : array()
The issue is that it's returning an error as if the eval string starts with "=", which I thought eval was trying to lookup for $array in the current scope, but assigning the variable beforehand didn't help. Escaping the dollar sign didn't work either, along with many other alternatives. Since the purpose is to json_encode the result, is there a better way to do it?
Источник: https://stackoverflow.com/questions/780 ... into-array
This is a strictly personal project, which is why I'm using eval.
The objective is to parse a string from a input form that contains an array, and cast it into an actual array so I can json_encode the result.
$result = @eval('$array = '.$data.';return true;'); example $data : array()
The issue is that it's returning an error as if the eval string starts with "=", which I thought eval was trying to lookup for $array in the current scope, but assigning the variable beforehand didn't help. Escaping the dollar sign didn't work either, along with many other alternatives. Since the purpose is to json_encode the result, is there a better way to do it?
Источник: https://stackoverflow.com/questions/780 ... into-array