How to access element of array
mikeerickson opened this issue · comments
Mike Erickson commented
Assuming you are loading from the ./composer.json
file, how would one get the first element of the array
$value = $config->get('authors[0].name');
$value = $config->get('authors.0.name');
If i were accessing as an array,
$value = $array["authors"][0]["name"];
Riku Särkinen commented
Have you tried these different ways to do it:
// Dot notation method
$value = $config->get('authors.0.name');
// Array reset() method
$value = reset($config->get('authors'));
// ArrayAccess method
$value = $config['authors][0]['name'];
pilishen commented
should put it into readme~