CodeIgniter Forums
I use CI setting library a lot but i miss one thing !!! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: I use CI setting library a lot but i miss one thing !!! (/showthread.php?tid=89309)



I use CI setting library a lot but i miss one thing !!! - luckmoshy - 02-04-2024

Hi All, I missed something here and I don't know yet,I propose it would be good to get the key in the array property like

PHP Code:
service('settings')->set('App.siteName.titleone''My Great Site'); /* == class, property array titleone ,titletwo 

Thank you


RE: I use CI setting library a lot but i miss one thing !!! - Ruzick - 02-15-2024

Hi, I use CI setting library too and I think I know what you mean. You want to access the array elements by using dot notation, right? Like this:

PHP Code:
echo service('settings')->get('App.siteName.titleone'); // prints 'My Great Site'

Unfortunately, I don't think the library supports this feature yet. You have to use the array index instead, like this:

PHP Code:
echo service('settings')->get('App.siteName')[0]; // prints 'My Great Site'

Hope this helps!