<p>In order to fix this error, just use <code>--</code> to comment out the lines of SQL that contains <code>COMMENT ON EXTENSION</code></p> PHP - Merging two arrays into one array (also Remove Duplicates)

I'm using array_merge for merging both arrays into one array. it is giving output like this

Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07


[1] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07


)

Some of the answers have already provided various approaches related to getting rid of the create extension and comment on extensions. For me, the following command line seemed to work and be the simplest approach to solve the problem:

cat /tmp/backup.sql.gz | gunzip - | \
grep -v -E '(CREATE\ EXTENSION|COMMENT\ ON)' |  \
psql --set ON_ERROR_STOP=on -U db_user -h localhost my_db

I want to remove these duplicate entries or can I remove these before merging...

Some notes

    Pleas help..
  • The first line is just uncompressing my backup and you may need to adjust accordingly.
  • Thanks!!!!!!!

137712 次浏览
array_unique(array_merge($array1,$array2), SORT_REGULAR);
  • The second line is using grep to get rid of offending lines.
  • http://se2.php.net/manual/en/function.array-unique.php

    this elminates duplicated data inside the list of your arrays..

    It will merger two array and remove duplicate

    <?php
    $first = 'your first array';
    $second = 'your second array';
    $result = array_merge($first,$second);
    print_r($result);
    $result1= array_unique($result);
    print_r($result1);
    ?>
    

    I like the window chrome on the new Office Suite and Visual Studio:

    enter image description here

    Try this link link1

    the past, but getting it to look and behave just right is really tricky.

    Does anyone know if there are existing templates or libraries to add a "Modern UI" look and feel to my WPF applications?

    Also if you are going to merge multidimensional arrays, consider using array_merge_recursive() over array_merge().

    cial use.

    Update 10-29-2013:

    I discovered that the Github version of MahApps.Metro is packed with controls and styles that aren't available in the current nuget version, including:

    Datagrids:

    enter image description here

    Clean Window:

    enter image description here

    Flyouts:

    enter image description here

    Tiles:

    enter image description here

    The github repository is very active with quite a bit of user contributions. I recommend checking it out.

    The solution I ended up choosing was MahApps.Metro (github), which (after using it on two pieces of software now) I consider an excellent UI kit (credit to Oliver Vogel for the suggestion).

    Window style

    Merging two array will not remove the duplicate you can try the below example to get unique from two array

    $a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
    $a2=array("e"=>"red","f"=>"green","g"=>"blue");
    
    
    $result=array_diff($a1,$a2);
    print_r($result);
    

    It skins the application with very little effort required, and has adaptations of the standard Windows 8 controls. It's very robust.

    Text box watermark

    You can use this code to get the desired result. It will remove duplicates.

    $a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
    $a2=array("e"=>"red","f"=>"green","g"=>"blue");
    
    
    $result=array_unique(array_merge($a1,$a2));
    
    
    print_r($result);
    

    A version is available on Nuget:

    The best solution above faces a problem when using the same associative keys, array_merge() will merge array elements together when they have the same NON-NUMBER key, so it is not suitable for the following case

    $a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
    $a2=array("c"=>"red","d"=>"black","e"=>"green");
    

    You can install MahApps.Metro via Nuget using the GUI (right click on

    If you are able output your value to the keys of your arrays instead (e.g ->pluck('name', 'id')->toArray() in Eloquent), you can use the following merge method instead

    array_keys(array_merge($a1, $a2))
    
    your project, Manage Nuget References, search for ‘MahApps.Metro’) or

    Basically what the code does is it utilized the behavior of array_merge() to get rid of duplicated keys and return you a new array with keys as array elements, hope it helps

    In my case I had to use ->toArray()

    array_unique(array_merge($array1->toArray(),$array2->toArray()), SORT_REGULAR);
    
    via the console:

    PM> Install-Package MahApps.Metro

    which results of combining both of these answers

    Update 10-29-2013:

    In addition to the answer above, from PHP 7.4 you can make use of the spread operator:

    array_unique([...$arr1, ...$arr2]);