note 130044 added to language.oop5.basic

From: Date: Thu, 20 Feb 2025 06:40:04 +0000
Subject: note 130044 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-221868@lists.php.net to get a copy of this message
// An anonymous function (also called a closure) in PHP is a function without a name, usually assigned to a variable or used as a callback. <?php // Define an array of numbers $numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Use an anonymous function to filter even numbers $evenNumbers = array_filter($numbers, function($num) { return $num % 2 === 0; // Return true if the number is even }); // Print the filtered array print_r($evenNumbers); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 45.115.104.151) ---- Manual Page -- https://php.net/manual/en/language.oop5.basic.php Edit -- https://main.php.net/note/edit/130044 Del: integrated -- https://main.php.net/note/delete/130044/integrated Del: useless -- https://main.php.net/note/delete/130044/useless Del: bad code -- https://main.php.net/note/delete/130044/bad+code Del: spam -- https://main.php.net/note/delete/130044/spam Del: non-english -- https://main.php.net/note/delete/130044/non-english Del: in docs -- https://main.php.net/note/delete/130044/in+docs Del: other reasons-- https://main.php.net/note/delete/130044 Reject -- https://main.php.net/note/reject/130044 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221868) next »