For example, I have an array
<code>$arr = array();</code>
How to make a string correspond to an (object/object reference)
Similar to std::map
For example, if you want to implement code similar to the following, how should you do it in PHP?
<code>class Obj { int var; } Obj my_obj = new Obj(); std::string str = "str"; std::map<std::string,Obj> s_o; s_0.emplace( {str,my_obj} ); </code>
Thank you everyone
For example, I have an array
<code>$arr = array();</code>
How to make a string correspond to an (object/object reference)
Similar to std::map
For example, if you want to implement code similar to the following, how should you do it in PHP?
<code>class Obj { int var; } Obj my_obj = new Obj(); std::string str = "str"; std::map<std::string,Obj> s_o; s_0.emplace( {str,my_obj} ); </code>
Thank you everyone
array('str' => new Obj())
PHP is weakly typed, any data can be passed to an array