There is a simple array $al_ext = array('bmp','png');
Displays

 Array ( [0] => bmp [1] => png ) 

There is such an array $al_ext2 = array($cat['type']); $cat['type'] $al_ext2 = array($cat['type']); $cat['type'] is taken from the database, extensions are also listed separated by commas, but for some reason they are displayed

 Array ( [0] => jpg,bmp ) 

Something I do not understand what the problem is.



    1 answer 1

    The variable $ cat ['type'] contains a string. It looks like this: "jpg, bmp" and you put this particular line in the array.

    For what you want to do, you can use the explode function .

    For example:

     $al_ext2 = explode(",", $cat['type']); 
    • And in the first case I have not a string? - vitagame
    • @vitagame, in the first case you have two lines separated by commas. - KryDos
    • Thanks for clarifying. - vitagame
    • Added more formats and it turned out Array ([0] => Array ([0] => jpg [1] => bmp [2] => gif [3] => jpeg [4] => png)) Yes even with two formats so. It should be a bit wrong. - vitagame
    • something is wrong. Please show the code. - KryDos