Robin S Posted February 14, 2018 Share Posted February 14, 2018 Is there a WireArray equivalent of PHP's array_search() function? In other words, if I have a value and I want to know the key of that value (if any) for a given WireArray, how can I do that? I checked the WireArray docs but didn't find any equivalent, which surprised me because array_search() is a pretty commonly used function. Would the only way be to convert the WireArray to a plain PHP array with getArray()? Link to comment Share on other sites More sharing options...
kixe Posted February 14, 2018 Share Posted February 14, 2018 $key = $wireArray->getItemKey($item); 3 Link to comment Share on other sites More sharing options...
Robin S Posted February 14, 2018 Author Share Posted February 14, 2018 Thanks @kixe! Why is this method undocumented I wonder? I'd love to know the criteria by which a method makes it into the API docs or not. I'd like to see all class methods documented. If the PhpDoc comments are already there (as they are in most cases) then where's the harm in making the information viewable in the API docs? @ryan? 1 Link to comment Share on other sites More sharing options...
kixe Posted February 14, 2018 Share Posted February 14, 2018 @Robin S The function is marked as #pw-internal and therefore not meant to be displayed in the docs. Why? No idea! Ask Ryan. The Api Docs have become much better in the last 2 years. Nevertheless, I mainly use the code itself as documentation. btw: Did you look here?https://processwire.com/apigen/class-WireArray.html Link to comment Share on other sites More sharing options...
Robin S Posted February 14, 2018 Author Share Posted February 14, 2018 1 minute ago, kixe said: Nevertheless, I mainly use the code itself as documentation. I guess I should do the same. It's just that Google is so convenient. I can see some benefits in having some introductory documentation that skips over the details. The earlier documentation was a bit like that and it's still useful. But for the v3 API Reference I think the more comprehensive the better. Having detailed and comprehensive documentation is not only useful to current users but it also boosts PW's credibility for potential users, particularly for experienced devs who I'm sure would find PW a pleasure to use and could make some valuable contributions to the community. The richness of the API is something we should show off rather than hide. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now