Jump to content

Search the Community

Showing results for tags 'find duplicate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. 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>"; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.