Little helper

From Sunhill Framework Documentation
Revision as of 20:04, 1 September 2024 by Klaus (talk | contribs) (created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

makeStdClass()

This function takes an associative array and converts it into a StdClass object. Example:

<?php

var_dump(makeStdClass(['a'=>1,'b'=>'abc']);

results in

object(stdClass)#1 (1) {
 ["a"]=>
 int 1,
 ["b"]=>
 string(3) "abc"
}

This function does the same as

(object)array('a'=>1,'b'=>'abc');