将数组投射到对象
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将数组投射到对象相关的知识,希望对你有一定的参考价值。
<?php /** * Note This has been tested on PHP5 * I haven't tried it on PHP4 */ "name" => "Jamie Allison", "age" => "31" ); // This is all that is required to cast an array to an object. $data = (object)$arr; // Next create an object manually, with the same data. // For comparison purposes below. $test = new StdClass; $test->name = "Jamie Allison"; $test->age = "31"; // Print out the Results, first dump the manually created class // Print out the Array Cast as an object. ?>
以上是关于将数组投射到对象的主要内容,如果未能解决你的问题,请参考以下文章