Monday 21, May 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

  Comparing two arrays using php

This code example will take two arrays and compares 2nd array with 1st. It will show the list of elements which are not found in the first array.
Cut & Paste Script
<?php
$ar1 = array(1,2,3,4,5,);
$ar2 = array(1,2,0,4,5);
$ar3 = array();

for($i=0; $i<count($ar2); $i++){
    $vartest=0;
    for($j=0; $j<count($ar1); $j++){
        if($ar2[$i]==$ar1[$j]){
            $vartest=1;
        }
    }
    if($vartest==0){
        $ar3[]=$ar2[$i];
    }
}

echo count($ar3)." elements not found in first array<br>";
foreach($ar3 as $val){
    echo $val."<br>";
}
?>
 
   
     RELATED SCRIPTS
 
Difference Between two dates using php
This function will return the number of days elapsed between two dates....more »
Category : PHP Examples Hits : 559
   
authenticating user with browser authenticate dialog box using php
Here is a script to authenticate user with browser authenticate dailog box. Username and password is hard codded in page and will be matched with user input....more »
Category : PHP Examples Hits : 508
   
Uploading file using php
Here is a simple script to upload file using php. we are using move_uploaded_file function to upload file. The move_uploaded_file function needs two parameters
1. The path of the temporary file.
2. The path where it is to be moved to.
...more »
Category : PHP Examples Hits : 429
   
creating new table in MySql using php
Here is an example to create a new table in mysql database....more »
Category : PHP Examples Hits : 657
   
Exporting data from MySql table to CSV using PHP
Here is a code example for exporting data from MySql table to a CSV File. CSV file format is a file type that stores tabular data usually processed in applications like Microsoft Excel....more »
Category : PHP Examples Hits : 1470
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download 12 Simple Ways to Promote your Website Ebook 12 Simple Ways to Promote your Website
   
Download Communication Network Ebook Communication Network
   
Download The Affiliate Marketers Master Guide Ebook The Affiliate Marketers Master Guide
   
Download Viral Marketing Mechanics Ebook Viral Marketing Mechanics
   
Download PC Assembly Language  Ebook PC Assembly Language
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz