?
avatar ztj1993
ztj1993
5 Feb 2018
        $Options = new Joomla\Registry\Registry(['cats' => [1 => '10', 10 => '100']]);
        $Arrays = (array)$Options->get('cats');
        var_dump($Arrays["10"], $Arrays[10]);
        exit();

Cannot get a value through a key; What's the matter, please?

avatar ztj1993 ztj1993 - open - 5 Feb 2018
avatar joomla-cms-bot joomla-cms-bot - change - 5 Feb 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Feb 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Feb 2018
Category Code style
avatar ztj1993
ztj1993 - comment - 5 Feb 2018
        $Options = new Joomla\Registry\Registry(['cats' => [1 => '10', 10 => '100']]);
        $Arrays = get_object_vars($Options->get('cats'));
        var_dump($Arrays["10"], $Arrays[10]);

So you can get it, please explain, thank you!

avatar OctavianC
OctavianC - comment - 5 Feb 2018

Nothing to do with Joomla! but how PHP converts objects to arrays:

If an object is converted to an array, the result is an array whose elements are the object's properties. The keys are the member variable names, with a few notable exceptions: integer properties are unaccessible;

See also this bug report

avatar ztj1993
ztj1993 - comment - 5 Feb 2018

@OctavianC Thank you!

avatar ztj1993 ztj1993 - change - 5 Feb 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-02-05 12:48:19
Closed_By ztj1993
avatar ztj1993 ztj1993 - close - 5 Feb 2018

Add a Comment

Login with GitHub to post a comment