Change
$data[$parts[0]] = $parts[1];
to
if ( ! isset($parts[1])) { $parts[1] = null; } $data[$parts[0]] = $parts[1];
or simply:
$data[$parts[0]] = isset($parts[1]) ? $parts[1] : null;
Not every line of your file has a colon in it and therefore explode on it returns an array of size 1.
According to php.net possible return values from explode:
Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.
If delimiter is an empty string (“”), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned.
Related Posts:
- How do I get PHP errors to display?
- How do I fix “Undefined variable” error in PHP?
- Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)
- PHP Fatal error: Using $this when not in object context
- Using $this when not in object context in PHP
- PHP parse/syntax errors; and how to solve them
- Python giving FileNotFoundError for file name returned by os.listdir
- Weird PHP error: ‘Can’t use function return value in write context’
- Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)
- Notice: Trying to get property of non-object error
- undefined offset PHP error
- What does the PHP error message “Notice: Use of undefined constant” mean?
- What is unexpected T_VARIABLE in PHP?
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- apache cpu over 70% on localhost
- Fatal error: Call to undefined method WP_Error::get_item_quantity()
- Fatal Error relating to sessions.php
- wp_ob_end_flush_all and wp_suspend_cache_addition()
- Why “Call to a member function on a non-object” in plugin only?
- fatal error call to undefined function get_header in index.php on line 1
- Getting error when using wp_insert_post()
- Fatal Errors on pluggable.php
- Syntax error in a shortcode function
- Fatal errors to undefined function in theme 404.php file [closed]
- PHP Helper Class to create shortcodes
- wordpress admin part is not accesbile after server shifting
- Error while loading wordpress site “Fatal error: Uncaught Error: Call to undefined function twentytwentyone_the_html_classes() in /home
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Connecting to upstream failed
- Fatal error: wp-settings.php on line 199
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- Fatal Error cannot log into wordpress and website disappeared
- pages disable after wordpress update
- Importing demo data in Multisite
- WordPress error on my website
- Changed URl in General Settings now WordPress site doesnt work
- Plugin Breaking WordPress Login
- WordPress won’t display errors at all
- WP white screen of death after duping a site that works fine on same server
- Catchable fatal error in appcloud free theme by Tokokoo
- How to fix ‘Call to undefined function do_settings()’ error?
- is_plugin_active() not defined on active plugin, in the thumbnails.php file
- White Screen When Includding A Folder With PHP Files
- Front-end major break after upgrade PHP 8.0 [closed]
- kali php problem [closed]
- Divi – add title to mobile menu button
- How to fix Fatal error: Cannot redeclare get_cli_args() in class-wp-importer.php
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted
- What does ‘=' mean in PHP?
- Setting Curl’s Timeout in PHP
- Double slashes on WordPress Admin URL redirects to wp-login
- WordPress category loop offset possible?
- Adding Custom Fields for Img in Posts
- How do I make wordpress comment fields required?
- Prevent WordPress from loading comments
- Go to / Scroll to Password Field on WordPress Posts After Submit With Message(s)
- Enhanced WordPress Search
- WordPress Redirect: Default Password Reset URL [duplicate]
- Wrap First Character after in a tag
- How to count custom post types with conditional operators
- How to Insert Shortcodes into Theme?
- How to filter posts by post format “standard” from wp-json api?
- Register JS for block on frontend only
- Why is file_get_contents returning page source?
- Woocommerce api: create product with images – bad request
- PHP Fatal error: Uncaught Error: Call to undefined function wp_kses_normalize_entities() in new wordpress installation
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Are nonces in WP REST API optional by default?
- How to insert HTML/JavaScript form into WordPress page? [closed]
- Custom gallery in wp3.5
- Creating a CSV with PHP inside the plugin directory
- Excecuting php function in shortcode
- do_action(), iFrame Gets Displayed Despite Password Protection [closed]
- esc_url( ) won’t use https
- Use post ID in functions.php file adminside
- How to show childs of certain custom post type in option list?
- How to edit HTML of my website on WordPress? [closed]
- wpdb Cannot Update column in Database
- Change default gallery images – Currently they are displaying full size imagese
- How to pick “full/thumbnail” images in the loop?
- A better code for no post format?
- AJAX function running TWICE with WordPress admin-ajax.php
- Sort new column in Users wp-admin
- How to create admin setting for this small plugin
- Custom PHP form needs refresh to load page correctly
- Child-Theme Category View with modified permalinks (%category% removed)
- Log out without confirmation request (nonce)
- Show data obtained from a function and place it in a shortocode function
- Delete empty title_tags, find a h1 heading and echo it
- Get posts from year from URL
- HELP: cannot log into wordpress. PHP error
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- Hide cart when empty [closed]
- Overwriting a Shortcode
- Is this WordPress code causing page weirdness? Can’t scroll to bottom
- Search result page – display values from the result’s metaboxes
- WordPress add parameters with friendly url structure
- Different behaviour between “include_once” and directly echoing out html code?
- Find owner of coupon
- WordPress wp_remote_request() – How to do async await in wordpress php?