我想对对象的属性进行排序,以便我可以按照定义的顺序循环它们.
例如:我有一个具有以下属性的对象'book':'id','title','author','date'.
现在我想循环遍历这些属性,如下所示:
foreach($book as $prop=>$val)
//do something
Run Code Online (Sandbox Code Playgroud)
现在循环的顺序必须是'title',然后是'author','date'和'id'
怎么会这样做?(我无法更改对象类中属性的顺序,因为那里没有定义任何属性,我使用'MyActiveRecord'从数据库中获取对象)
我需要从字符串中调用PHP标准函数
例:
$param = "parameter";
$functionname = "createimagefromjpg";
//call the function (with a parameter)
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何做到这一点?它无法完成,call_user_func()因为它是一个标准功能.