If it’s just a list of numbers, I’d suggest just saving them in a text file, with a number on each line.
110019
111222
112233
Then when you need the file, read its contents with PHP, and use preg_split()
to turn it into an array:
$file_path = plugin_dir_path( 'postcodes.txt', __FILE__ ); // Or wherever you've placed it.
$file_contents = file_get_contents( $file_path );
$postcodes = preg_split( "/\r\n|\n|\r/", $file_contents );
if ( in_array( $postcode, $postcodes ) ) {
}
That preg_split()
method for splitting text based on newlines is taken from here.
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- How to call a PHP function from Javascript in WordPress
- How to preserve PHP modifications while upgrading WordPress?
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Shortcode created to check language not works
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- How to Append to the_excerpt() Function
- Listing all sub-pages?
- Why do filters/actions require an argument count?
- How can I default to all WordPress roles when parameter is not included in shortcode?
- Recent post display using shortcode
- How to speed up a wordpress function with multiple loops?
- syntax issue on php 7.4
- How can I use wp_insert_comment to write a comment when a post is edited?
- How to remove the excerpt in the Dzonia Lite theme
- How do you add customer capability after Woocommerce purchase?
- Add a class to the anchor tag on HTML5 gallery
- Conditional Header in wordpress
- Menu — How to add “current-menu-grand-ancestor” css class
- functions.php is being included twice, creating PHP fatal errors
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to put a variable in a instance in the widget
- get a simple array of all of the term names that exist in all taxonomies
- Logged in user ID as post ID
- Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category
- How to store data from multiple forms using ajax and php
- How to control WordPress image metadata (using Imagick)?
- Display a specific category of products in shop page and disable code for specific actions
- Removing “wpautop” (auto tags) only on certain pages?
- Trying to retrieve post meta
- Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose
- Use .php file as page instead of wordpress page & template file?
- Find hours between post_date and post_date_gmt
- Run a code only on theme activation only during first activation
- Plugin Generate Unexpected output during activation
- Remove Custom Divs from AMP pages
- Read array in php?
- Tell WP register script to load a script only when the entire page is loaded
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- PHP code for displaying WordPress posts in a static page not working
- Remove extract from function
- Undefined offset: 3 in custom function
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to add data to a custom field at the wp_users table?
- How can I use custom menus with a Bootstrap WordPress theme?
- How to make a cookie be on the whole site instead of being on a specific page/
- Child Theme’s Read More Text
- call a string/function from database
- Get date function not working
- How to implement __() function in my theme’s php file?
- Can/should we delete wordpress cron jobs with no action?
- How a HTML form can trigger a PHP function?
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Display Visual Composer shortcode if a post belongs in specific categories
- Get current user id in function php
- Proper way to remove html code on child theme
- Trying to add Custom Post Type to this functions.php command
- Apply function.php filter only if url not has /amp/
- Preventing direct access to a page in WordPress
- How to use data URL in WordPress?
- Flushing the slug base has no effect and does not change
- Display a custom name when the user has no name settle in his account
- Multiple cron jobs vs daily cron job doing multiple things? Which one yields better performance and scalability?
- Discount in the specific product title using keyword ( Woocoommerce )
- Modify post image in full size
- How to link all featured images to custom url in single.php for only non-logged-in users?
- JQuery modal not loading video on popup, only displaying it after multiple reopenings
- Get user by meta data key and velue
- Logo custom width not implementing
- custom post type column countdown
- Add another role to a user when they click a button?
- Using wordpress functions in class and change my code to OOP PHP
- Creating wordpress user registration form
- Add missing alt tag to featured images for “storefront” theme
- Notice: Undefined index: post_title error
- Unable to pass arguments to function used in add_action
- What is the proper way to call a function (from functions.php) on a link click?
- Load admin bar without wp_head or wp_footer [duplicate]
- Allow user to select location and then set cookie for location in WordPress
- My query keeps looping infinitely ! how to stop it?
- Highlight Single Page Ancestor
- Registration form not registering First and Last name
- Removing get_template_part in child theme
- Merge / Combine two php functions for Previous and Next Link with Thumbnail
- str_replace not responding in functions.php [closed]
- Display a list of users with avatar filterable with alphabets
- Change default comments form title [duplicate]
- How to get the rating value of each comment
- Adding php within a return statement [closed]
- Displaying categories
- Error in php code
- Replace the image of a product with its video in the shop page
- Too few arguments to function woocommerce_update_product_acf_save_post()
- WordPress Importer Call to undefined function set_time_limit()
- Display terms on product page with shotrcode
- How do I get a function to work in single.php
- WordPress different custom tag being displayed in on tag list
- Exclude a category ID from the following function
- Add text below WooCommerce short description if metabox value is true
- ACF number less than comparison not working