Ola!
So I got a $_POST looking like:
Array
(
[name] => FooBar
[sobject] => tbl_character
[id] => 102
)
And a "SmartObject" like:
SmartObject Object
(
[_settings] => Array
(
[table] => tbl_character
[ignores] => Array
(
[0] => leaderid
[1] => typeid
[2] => senderid
[3] => recieverid
[4] => imageid
[5] => fileid
[6] => professionid
[7] => id
)
[prefix] => tbl_
)
[id] => 102
[worldid] =>
[accountid] => 110
[zoneid] =>
[raceid] => 1
[imageid] =>
[name] => asd
... blabla more data
)
What I want to do is to loop through the $_POST and check if the keys match any public set property on my SmartObject like so:
foreach($_POST as $key => $value) {
if(isset($object->{$key})) {
$object->{$key} = $value;
}
}
When a value exists (ex. for id) the isset triggers and returns true, but when a value doesn't the isset wont return true.
empty() checks if a value is set.
isset() should check if the "variable" or "property" is there, not necessarily set to anything, right?
I believe this code worked fine for me a year ago, but now the if-statement wont trigger on name. Am I doing something wrong? Has the fundamentals of php changed?