A
A
Alexander Interesting2020-04-14 01:43:21
PHP
Alexander Interesting, 2020-04-14 01:43:21

How to get the minimum value of an array given its name?

Hello, I need a code that will return 2 values, namely "Array string names" and "Value of this string"
For example:

<?php
    $xml = simplexml_load_file("xml.xml");
    $dates = array();
    foreach($xml as $line){
        $dlg = array(".", ",", ":", " ");
        replaced = str_replace($dlg, "", $line->name);
        $rdate = date(d.m.Y.H.i.s) - $replaced;
        //Здесь нужно сделать определение на самое маленькое значение массива + его название, крч мне нужен объект у которого самое маленькое значение в массиве
    }
?>

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-14
@FanatPHP

inside the loop, compare the current value with the previously written one.
if the current one is less - write it and the key to a variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question