1

I have this simple array defined:

1: <?php
2: $_ext = array(
3:  array('doc', 'docx'),
4:  array('xls', 'xlsx'),
5:  array('ppt', 'pptx'),
6:  array('php'),
    array('html'),
    array('pdf'),
    array('js').
    array('java'),
    array('zip', 'rar')
  );

When I run it i get the following error

NOTICE Array to string conversion on line number 3

NOTICE Array to string conversion on line number 3

I even tested this on the webpage http://phptester.net/ and I got the same error. I don't know which php version my host is using but probably the newest.

I read this w3schools article (https://www.w3schools.com/php/php_arrays_multi.asp) about multidimensional arrays and I don't really know what I am doing wrong.

Thank you in advance for your help. :)

1
  • The code you give, when including delx's answer works fine for me. Commented Jul 26, 2017 at 18:49

1 Answer 1

4

Check the line array('js').. There's a typo: Try replacing the point with a comma.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, this solved the error. Will mark this question as the right one as soon as it allows me to. I still don't understand why it gives the error on line 3 when the error somewhere else. @Martin
Because that's the line it started adding the array elements on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.