You chose 2-bed(s) rooms and they are in hotel- 4 . Kind of room 2 bed(s) 2015-01-13 2015-01-21 Connected successfully2015-01-132015-01-142015-01-152015-01-162015-01-172015-01-182015-01-192015-01-20Kind of room 3 bed(s) 2015-01-13 2015-01-21 Connected successfully
2015-01-132015-01-142015-01-152015-01-162015-01-172015-01-182015-01-192015-01-20Kind of room 2 bed(s) 2015-01-16 2015-01-21 Connected successfully
2015-01-162015-01-172015-01-182015-01-192015-01-20Kind of room 2 bed(s) 2015-01-18 2015-01-21 Connected successfully
2015-01-182015-01-192015-01-20
No duplicates found.
Those dates they are arrays it is altogether $result[$x].
I can't find duplicate in array
$link = mysql_connect('','', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db();
$row["datefrom"]= strtotime( $row["datefrom"]);
$row["dateto"] = strtotime($row["dateto"]);
// Loop until we reach the last day
$result = array();
while ($row["datefrom"] <= $row["dateto"] ) {
if (date('N', $row["datefrom"]) <60) {
$result[] = date('Y-m-d', $row["datefrom"]);
}
$row["datefrom"] = strtotime('+1 day', $row["datefrom"]);
}
$sql="select datefrom, dateto, rooms, count(*) as duplicates from rooms group by datefrom, dateto, rooms order by datefrom, rooms limit $brsoba";
// Show the result
// You could loop the array to pretty-print it, or do it within the above loop
array_pop($result);
sort($result);
echo "<pre>";
$arrlength = count($result);
for($x = 0; $x < $arrlength; $x++) {
echo $result[$x];
echo "<br>";
$test = array('$result[$x]');
$result[$x] = getArrayDups($test);
}
//$result[$x]= array( $result[$x]);
//$result[$x]= array_count_values($result[$x]);
//
//
//foreach( $result[$x] as $result[$x]=>$value)
////echo "$key - <strong>$value</strong> <br />";
//
//
//{
//
}
function getArrayDups($array)
{
$counts = array_count_values($array);
return array_filter(
$counts,
create_function(
'$val',
'return($val > 1);'
)
);
}
// usage test:
$test = array('$result[$x]');
$result[$x] = getArrayDups($test);
if(count($result[$x]))
{
echo "<p>You had one or more duplicate entries:</p>\n<ul>\n";
foreach($result[$x] as $entry => $count)
{
echo "<li>$entry ($count)</li>";
}
}
else
{
echo "<p>No duplicates found.</p>";
}