Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
附加本身是微不足道的:
$obj->lorem = 'ipsum';
假设对象具有 和 之类的属性foo,bar则将在lorem末尾添加。这是有道理的,但是……</p>
foo
bar
lorem
我怎样才能插入lorem让我们说在 foo and bar之间?
我假设我必须遍历对象字段,您能否阐明最有效的方法?
For simple objects, you can use the associative array syntax and casting to get an object.
Example:
<?php $obj = (object)array('lorem' => 'ipsum', 'foo' => 'bar'); echo $obj->lorem; //echo ipsum echo "</br></br>"; echo $obj->foo; //echo bar ?>