PHP: Find maximum odd number of sequence in an array

This is php program that finds the maximum odd number of sequence in an array. By editing, in case of even number also be found out.

Code:
[php]
<?php
$x = array(1,7,4,5,7,5,6,3,4,6,87,53,45,567,45,43,66,56,57,5);
$tot = count($x);
$y = $res = array();
$y[0] = array();
$k = $j = 0;
for($i = 0; $i $val)
if($max == count($val))
$k = $key;

echo “The number of maximum odd sequesnce: $max
The numbers are:”;
var_dump($y[$k]);

?>
[/php]

Waiting for any better solutions. :)

Leave a Reply

%d bloggers like this: