$users = array( array('name' => 'John', 'age' => 25), array('name' => 'Jane', 'age' => 30), array('name' => 'Mike', 'age' => 35) ); $firstUser = pick($users[0], 'name'); echo $firstUser; // Output: John
class Product { public $id; public $name; public $price; public function __construct($id, $name, $price) { $this->id = $id; $this->name = $name; $this->price = $price; } } $products = array( new Product(123, 'Phone', 500), new Product(456, 'Laptop', 1000), new Product(789, 'TV', 800) ); $productPrice = pick(array_values(array_filter($products, function($p) { return $p->id == 123; }))[0], 'price'); echo $productPrice; // Output: 500In this example, we filter the products array to only include the product with ID 123, extract the first element of the resulting array, and then use the pick function to extract the price of that product. Package library: It is not specified which package library the PHP Helper Pick belongs to, but it is most likely a custom library developed by the author or a small open-source library available on platforms like GitHub or Packagist.