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?
- “Object-cache.php” disables wp_cron and even disables my entire site, and keeps reappearing by itself again after I delete it
- PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in Stack trace:\n#0 [internal function]: img_caption_shortcode()
- Adding slides to an existing carousel manually
- Where to store the images of a custom WordPress theme?
- How to dynamically change webcam photo timestamps
- how to add “alt” for all image in wordpress
- How to replace wp-admin login page to another location?
- Shortcode to include PHP file, pass various parameters to include?
- How to find the value of the user password in wordpress and send it to another server via rest api
- Exclude specific product tags from related products in WooCommerce 3+ [closed]
- Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 42240 bytes) in /home/dh_w7t9sk/morleywines.com/wp-content/plugins/
- Visual Composer Data Source?
- wp_query on search results page showing all results every time
- Why can’t I include echo inside a variable? [closed]
- Errors using WAMP for local hosting site and Dreamweaver to edit theme
- WP_Query not returning results
- WooCommerce Orders pagination
- Problem with function.php.. like
- How to manage wordpress knowledge base/wiki/posts collections
- Simple Probléme in wordpress
- Custom Registration and Login Forms with reCaptcha 2 Validation
- image dimension in php code args
- How to add pagination for wordpress home page
- Import and use a variable in additional settings of Contact Form 7 [closed]
- which php or css file has generated an inline style in WordPress that overwrites my css
- Change Checkout “Place Order” text if cart has a specific product
- php inside HTML via shortcode? [closed]
- How to hide Ads From Certain Categories?
- Using Excel formula in PHP. Use ^ symbol [closed]
- Fatal error: Call to undefined function wp_cache_get after update attempt
- Change body_class() PAGE to HOME
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- PHP warning Invalid argument supplied for foreach() on custom page template
- Woocommerce disable checkout on specific day
- Populate Woocommerce order notes with custom field value
- HELP! Fatal Error? I can’t access the Dashboard. How do I regain access? [closed]
- how to put shortcode to the top of the page – theme 2014
- display php code in header using wp_head()
- How to string lines from the_content() hook in WordPress?
- How to insert current “login” page to certain page?
- Why functions metaboxes is causing White Screen in Admin [closed]
- foreach all the post
- Woocommerce Product Add-ons – Auto-select first option
- Pagination 404 on my index.php
- Call custom posttype outside the functions.php
- ACF loops false value with repeater and checkbox
- How to avoid timeout waiting for output from CGI script?
- Passing javascript variable to php file
- Jquery autosave text area after typing
- Get custom post fields and display them