How to sort an array by key to match another array’s order by key [PHP]

sometime you have two arrays, both have the same keys (different values) however array #2 is in a different order. you want to be able to resort the second array so it is in the same order as the first array.

Is there a function that can quickly do this?

yups to do this you can use foreach and reorder array #2 like below:

$arr1 = array(
    'a' => '42', 
    'b' => '551',
    'c' => '512',
    'd' => 'gge',
) ;

$arr2 = array(
    'd' => 'ordered',
    'b' => 'is',
    'c' => 'now',
    'a' => 'this', 
) ;

$arr2ordered = array() ;

foreach (array_keys($arr1) as $key) {
    $arr2ordered[$key] = $arr2[$key] ;


then the result will be like this:

Array ( [a] => this [b] => is [c] => now [d] => ordered )


How to fix: AnyConnect error after updating macOS Catalina

How to fix AnyConnect error: cannot confirm it is connected to your secure gateway.  The local network may not be trustworthy.  Please try another network

after a few day update macos catalina, i realize i have problem with anyconnect. everytime i try to connect, Cisci AnyConnect: Got an error like this:

AnyConnect cannot confirm it is connected to your secure gateway.  The local network may not be trustworthy.  Please try another network

after browsing and googling a few minute… i found solution in here

open terminal and do the following (you will need administrator rights on your Mac)

cd /opt/cisco/AnyConnect

sudo nano AnyConnectLocalPolicy.xml

Then edit the field for ExcludeMacNativeCertStore to "true"


^X  (control X to exit)
press Y to indicate that you want to save
press enter to accept the existing name

Quit AnyConnect and start it up again.  You will now receive a certificate warning with the option to continue and, if available, install the certificate.

and just that… my anyconnect error gone….


Select2 js Ajax Chained Snippet

snippet how to use ajax chained in select2 js

Snippet wordpress

Add a custom post type menu as a child of an existing custom post type menu.

How to add submenu Custom post type as a child of an existing Custom post type menu.


Import image to WP and set as Featured Image

this code is for import image to WordPress Media then set as Featured Image in Post

Snippet wordpress

How to get WordPress attachment caption, title, alt, and description

this si simple function to get all wordpress attachment text

Javascript Snippet

How to get parameter querystring value from URL with javascript


Create Loop Row with Colum bootstrap – PHP


How to add adsense before and after the_content()

konsep pada snippet kali ini adalah kita ingin melakukan hook filter pada fungsi the_content() untuk menampilkan adsense sebelum dan sesudah the_content() / area konten utama.

berikut snippet yang bisa di gunakan:

snippet di atas bisa di gunakan untuk memasukkan berbagai macam data/text atau info lainnya.


Create custome permalink for custome page & API

pada kasus kali ini kita akan membuat dinamic URL yang bisa di cache oleh wp supercache dengan data yang di peroleh dari API.

custome URL permalink yang akan kita buat kali ini seperti ini:

page-name :  page name halaman yg kita buat

data-id: id yang akan kita gunakan untuk memanggil data dari REST API

datatitle: page title permalink agar mudah di baca

step 1

daftarkan permalink tersebut ke wordpress:

setelah itu kita buat custom page template untuk menarik data tersebut dan tambahkan kode berikut:
$url = explode( '/', $_SERVER['REQUEST_URI'] );
echo "<pre>";
echo "</pre>";
setelah itu coba akses halaman tersebut
maka akan muncul seperti di bawah ini:
    [0] => 
    [1] => peserta
    [2] => 6AWbaqqrj28
    [3] => laras-hati-dewa-dewi
    [4] => 
data dari array tersebut bisa di gunakan untuk memanggil data dari REST API dari situs lain.