PHP check if an item is inside a multi dimensional array
Here’s the Stackoverflow link
Here’s the improved answer
//The Function
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
$found = 'yes';
}
}
$found = 'no';
return false;
}
//The Function in use
//Set the result as a var so you can check it.
$found = in_array_r($search_pre_order_date,$dates_array) ? 'found' : 'not found';
//If the result is equal to something do something...
if ($found == 'found') {
echo 'Yes this item is in the array';
}elseif ($found == 'not found') {
echo 'Nope not in the array';
}
Change the featured image text on custom post type
add_action( 'admin_head', 'remove_my_meta_boxen' );
function remove_my_meta_boxen() {
remove_meta_box( 'postimagediv', 'countries', 'side' );
add_meta_box('postimagediv', __('Country Flag'), 'post_thumbnail_meta_box', 'countries', 'side', 'high');
}
The post type in this example is countries
Simple Back Button
<a href="javascript:history.go(-1)" class="custom_back_button"><i class="fas fa-chevron-left"></i> Back</a>
This example uses Font Awesome. Don’t forget to include Font Awesome lib in your functions.php
Initiate Jquery and Javascript
jQuery(document).ready(function($) {
// Test
console.log( "ready!" );
});
© Garth Baker 2025 All rights reserved.