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
- Error message not appearing in error email or in the error log
- Why PHP Parse unmachet after update to PHP8?
- PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in Stack trace:\n#0 [internal function]: img_caption_shortcode()
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- What are the differences in die() and exit() in PHP?
- When should I use ‘self’ over ‘$this’?
- Eclipse returns error message “Java was started but returned exit code = 1”
- How to use PHP inside css file
- Getting the screen resolution using PHP
- PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/website/public_html/facebook/fbclogin.php on line 57 [duplicate]
- PHP: fopen() Permission denied
- Redirect old php link to wordpress link in .htaccess
- What is the meaning of ‘OFFSET’ => 1 (WordPress)
- WordPress custom thumbnail size
- Random Question Mark Icons In WordPress Text
- What does arg mean in WordPress
- WordPress dFactory Cookie Notice Plugin
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- Include a external PHP file into a WordPress Custom Template
- Can I use traits? Or will I cut out a large portion of the community?
- Is it possible to create an “export to PDF” option?
- Does the REST API (official) support custom post types?
- Can we have a php “page” without a WordPress “page”?
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- How to get Woocommerce Variation ID? [closed]
- functions.php not adding css to website?
- Why is my get_post_meta always empty
- Geocoding an Exploded Custom Field Array
- Count Title and Post Characters
- Inserting data into `post meta` table?
- fetch_feed: retrieve entries in the appearing order, not chronologically
- HTML table from shortcode with multiple parameters
- WooCommerce: update custom fields after checkout validation failure
- Programmatically create menu with custom link
- I am having a problem with form updating/editing WordPress post on the frontend
- What does this mean: Object of class WP_Error could not be converted to string
- get_users(…) only returns one user
- Get post thumbnail from subpages with a foreach loop
- Get PHP Fatal error on globalized $wpdb: Call to a member function insert() on a non-object- I have no clue. What to do?
- How to disable the password strength meter script on reset password page?
- WordPress takes too much time (100 seconds) to load – Front end and back end
- Dynamic Stylesheet loads but doesn’t finish
- how to change the verification url of pie register plugin of wordpress?
- add custom link to wordpress media gallery modal
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- How to show single category archive
- Dynamic content based on a URL parameter
- Server configuration for WordPress – Do I need install PHP-SSH extensions for WordPress on Fedora28?
- Hide subcategories (widget)
- How to Reference/Echo Variable from Another PHP Function
- Replace shortcode in substring
- Using color picker in plugin, does input attribute order matter?