In some cases you might have a structured array from the database and oneof its nodes goes like this;<?php$arr = array( 'name' => 'some name', 'key2' => 'value2', 'title' => 'some title', 'key4' => 4, 'json' => '[1,0,1,1,0]');$keys = array( 'name', 'json', 'title' );?>Now consider that you want to capture $arr values from $keys.Assuming that you have a limitation to display the content into given keysorder, i.e. use it with a vsprintf, you could use the following<?php$string = "<p>name: %s, json: %s, title: %s</p>";$keys = array_flip( $keys );$test = array_intersect_key( $arr, $keys );echo vsprintf( $string, $test );$test = array_replace( $keys, $test );echo vsprintf( $string, $test );?>I hope that this will save someone's time.