-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assistance with example #24
Comments
Hi, If you can do it based on key name, have you tried to use array_flip, in order to use values as keys in your array ? |
My apologies, I didn't quite explain properly. I had an array of Entries, and then within each entry a set of definitions, along with another array. It wasn't pretty, and there are likely better ways to go about it, but this was my method of resolution: $root = $plist->getValue(true);
$entries = $root->get('Entries');
foreach ($entries as $entry) {
$topalias = $entry->get('versions')->getValue();
foreach ($topalias as $subvalue) {
$finalvalue = $subvalue->get('versionAliases')->getValue();
}
$versionalias = $finalvalue;
} The $versionalias having been the entry I was pulling from that second tier array. Again, not pretty, but it worked. Thanks for the quick response, and if there's a more efficient method, I'd love to hear it. Thanks! |
As the API stands today, there is not a more efficient approach than the one you chose. In terms of working with That said, it would be possible to implement an xPath / CSS-selector like approach to navigate within a I'd be happy to merge a PR resolving this ;) |
I've scoured trying to find an example to pull a selected field from an array. I can pull fields based on key name just fine, however having an issue determining how to utilize CFP to pull a value from an array, using PHP.
Any assistance would be greatly appreciated. I've greatly appreciated the library having been made available thus far, thanks guys!
The text was updated successfully, but these errors were encountered: