Highest numerical value of an array

Let's say that we have a file with the following strings:
100
3
876
55
When I open the file for reading I would like just to get the highest value. Any one knows how to do this in Kix.
kt2003Asked:
Who is Participating?
 
Loganathan NatarajanConnect With a Mentor LAMP DeveloperCommented:
better you post it in VB section..if u don't want the solution in php
0
 
Loganathan NatarajanLAMP DeveloperCommented:
i think this will work,

<?php

echo max(1, 3, 5, 6, 7);  // 7

echo max(array(2, 4, 5)); // 5

?>

just take a look at

http://in2.php.net/max

NOTE: Make sure when you read the values ... convert as ARRAY.. then pass to this function
0
 
Oddsen84Commented:
"Let's say that we have a file with the following strings:
100
3
876
55
When I open the file for reading I would like just to get the highest value. Any one knows how to do this in Kix."


<?php
$array_result = max($array_name);
?>

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
kt2003Author Commented:
Let me try.
0
 
dr_dedoCommented:
u could use \r instead of \n if it doesn't work for u
$data = file_get_contents('c:\new.txt');
$data = explode("\n",$data);
echo max($data);

Open in new window

0
 
kt2003Author Commented:
Now. It doesn't work.
Let's say we have in Kix's code something like:

if open(1, $FilePath,2) =0
   $line = READLINE(1)
       WHILE @ ERROR = 0
         ?$line
       $line = READLINE(1)
    loop
endif

I just want $line to give the highest value.
0
 
dr_dedoCommented:
don't know about kixtart, but if you know it, then need to read the whole file, line by line, and save each line as an element in an array. if there is a max function in kixtart then use it, else, create your own
0
 
kt2003Author Commented:
Thank you.
0
 
kt2003Author Commented:
Come on gurus. Any other ideas are welcome.
0
 
Oddsen84Commented:
You are running PHP??? In case what version???
0
 
kt2003Author Commented:
No i am running any version of PHP.
0
 
dr_dedoCommented:
if you are asking for syntax, then you are in the worng area, i see you are posting to php and VB, your desired language is none of them.
if you are asking for ideas, i guess i gave you one.
if you don't know kixtart, then switch to something else as php or even asp. i dont see many using kixtart
0
 
kt2003Author Commented:
Thank you I will.
0
All Courses

From novice to tech pro — start learning today.