Jump to content

array_filter question


silverglade

Recommended Posts

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");

Link to comment
https://forums.phpfreaks.com/topic/239596-array_filter-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.