Comments (3)
Hi,
I think I don't understand what you mean by "pull a value from an array". Maybe I can help you if you can clarify your need to me.
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 ?
from cfpropertylist.
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!
from cfpropertylist.
As the API stands today, there is not a more efficient approach than the one you chose. In terms of working with $plist
that is. One could probably optimize the looping (unless you really want the very last $finalvalue
of the very last $entry
).
That said, it would be possible to implement an xPath / CSS-selector like approach to navigate within a $plist
. Something that would convert your above looping thing into $versionalias = $plist->find('versions:last/versionAliases:last')->getValue();
I'd be happy to merge a PR resolving this ;)
from cfpropertylist.
Related Issues (20)
- CFPropertyList object is not serializable HOT 3
- Add documentation and more examples
- Packagist package has the wrong name HOT 1
- CFPropertyList Problem HOT 14
- new CFNumber(0) = format error HOT 4
- TypeDetecting Dictionary fails HOT 1
- Error reading large plist files HOT 6
- Maintainers Wanted HOT 12
- Information for project site HOT 1
- DevOps tasks
- HTML-Proofer found 2 failures
- Uncaught exception HOT 9
- How to disable base64 decoding? HOT 2
- Package does not auto-update on packagist HOT 2
- Output of toXML() for <real>s is locale-dependent and causes creation of invalid PList-XML HOT 4
- PHP 8.1 Compatibility HOT 23
- `CF$UID` cannot be squashed to integer HOT 2
- Can I directly use plist data in variables? HOT 1
- CFDictionary should not allow adding empty keys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cfpropertylist.