$userData = array( array('name' => 'John', 'age' => 25, 'email' => 'john@example.com'), array('name' => 'Jane', 'age' => 30, 'email' => 'jane@example.com'), array('name' => 'Bob', 'age' => 40, 'email' => 'bob@example.com') ); $emailAddresses = JArrayHelper::getColumn($userData, 'email');
array( 'john@example.com', 'jane@example.com', 'bob@example.com' );
$products = array( array('name' => 'Product 1', 'price' => 20, 'available' => true), array('name' => 'Product 2', 'price' => 30, 'available' => false), array('name' => 'Product 3', 'price' => 25, 'available' => true), array('name' => 'Product 4', 'price' => 50, 'available' => true) ); $availablePrices = JArrayHelper::getColumn($products, 'price', 'available', true);
array( 20, 25, 50 );In this example, we're using an additional parameter in `getColumn` to filter only the products that have an `available` value of true. The `JArrayHelper` package is part of the Joomla Framework.