-1

Hi I am getting the following message in my wordpress filter page for a holidays website:

Warning: Illegal string offset 'order' in /home/jefmaher/public_html/wp-content/themes/thevacationrental/functions.php on line 916

Warning: Illegal string offset 'order' in /home/jefmaher/public_html/wp-content/themes/thevacationrental/functions.php on line 917

This is the snippet of php

$i = 9999;
foreach( $options['customdatas'] as $key => $data ) {
    if( empty( $data['order'] ) ) {
        $options['customdatas'][$key]['order'] = $i;
        $data['order'] = $i;
    }

I am new to php and need some advice please

thanks

Jeff

  • 1
    `$options['customdatas'][$key]['order'] = $i;` and `$data['order'] = $i;` do the same thing. – xlecoustillier Feb 19 '15 at 14:49
  • possible duplicate of [Illegal string offset Warning PHP](http://stackoverflow.com/questions/9869150/illegal-string-offset-warning-php) – Jon Surrell Feb 19 '15 at 14:53
  • possible duplicate of [Warning: Illegal string offset in PHP 5.4](http://stackoverflow.com/questions/16264115/warning-illegal-string-offset-in-php-5-4) – Slavic Feb 19 '15 at 14:58

1 Answers1

1

"Illegal string offset" message indicates $data is not an array but rather a string, in, at least, one of the cases of foreach. One way to fix is to check if $data is, in fact an array.

if (is_array($data)) ;//
Slavic
  • 1,891
  • 2
  • 16
  • 27