silverglade Posted June 16, 2011 Share Posted June 16, 2011 Hi, I have a question about the "array_filter" function for php arrays. Here is the sample code. I have commented my question next to the code. The code filters out code that does not begin with y. An array with just the names that end with Y are returned. Any help greatly appreciated. Thank you. function endswithy($value) { return (substr($value, -1) == 'y'); // What does "substr($value,-1) == 'y');" do here } $people = array("Johnny","Timmy","Bobby"."Sam"); $withy = array_filter($people, "endswithy"); Quote Link to comment https://forums.phpfreaks.com/topic/239596-array_filter-question/ Share on other sites More sharing options...
requinix Posted June 16, 2011 Share Posted June 16, 2011 The code filters out code that does not begin with y. The function is called "endswithy" for a very specific reason Here's the manual page for substr(). Read over that. Quote Link to comment https://forums.phpfreaks.com/topic/239596-array_filter-question/#findComment-1230819 Share on other sites More sharing options...
silverglade Posted June 16, 2011 Author Share Posted June 16, 2011 Awesome thank you requinix, in the future I will try to find it in the manual. Thank you for that link. I understand it all now. :) Quote Link to comment https://forums.phpfreaks.com/topic/239596-array_filter-question/#findComment-1230835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.