Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4582456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:04:38+00:00 2026-05-21T21:04:38+00:00

I have an array like this: array (0 => array ( ‘id’ => ‘20110209172713’,

  • 0

I have an array like this:


array (0 => 
  array (
    'id' => '20110209172713',
    'Date' => '2011-02-09',
    'Weight' => '200',
  ),
  1 => 
  array (
    'id' => '20110209172747',
    'Date' => '2011-02-09',
    'Weight' => '180',
  ),
  2 => 
  array (
    'id' => '20110209172827',
    'Date' => '2011-02-09',
    'Weight' => '175',
  ),
  3 => 
  array (
    'id' => '20110211204433',
    'Date' => '2011-02-11',
    'Weight' => '195',
  ),
)

I need to extract minimal and maximal Weight values.
In this example

$min_value = 175

$max_value = 200

Any help on how to do this ?
Thank you !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:04:39+00:00Added an answer on May 21, 2026 at 9:04 pm

    Option 1. First you map the array to get those numbers (and not the full details):

    $numbers = array_column($array, 'weight')
    

    Then you get the min and max:

    $min = min($numbers);
    $max = max($numbers);
    

    Option 2. (Only if you don’t have PHP 5.5 or better) The same as option 1, but to pluck the values, use array_map:

    $numbers = array_map(function($details) {
      return $details['Weight'];
    }, $array);
    

    Option 3.

    Option 4. If you only need a min OR max, array_reduce() might be faster:

    $min = array_reduce($array, function($min, $details) {
      return min($min, $details['weight']);
    }, PHP_INT_MAX);
    

    This does more min()s, but they’re very fast. The PHP_INT_MAX is to start with a high, and get lower and lower. You could do the same for $max, but you’d start at 0, or -PHP_INT_MAX.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an array like this: string [] Filelist = ... I
When you have an array like this: int foo[3][2][2]; and you make: int *bar
I need to move backwards through an array, so I have code like this:
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have an array like this: $array = [ 0 => 'Apple', 2 =>
I have an array like this: object[] args and need to insert those args
I have an array like this: array(a => 2, b => 4, c =>
I have an array like this: $options[0] = 1; $options[1] = 2; $options[2] =
I have an array like this: $sports = array( 'Softball - Counties', 'Softball -
I have an array like this. What i want is to get the value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.