Is it possible to check the size of a string inside an array?

2

I have an array that is built by the selected chekbox results ...

It returns with var_dump :

array(3) { [0]=> string(7) "BXT0022" [1]=> string(7) "BXT0010" [2]=> string(7) "BXT0024" }

If you have something in the array or if it is empty,

string(0) ""
How can I do an if (does not have anything in the array ) does the implode ... I tried with count of the array but always gives 1 even with nothing chosen, issset also has something there and it does not work ... I do not know what else to use ...

Does the array return the length of the string ?

    
asked by anonymous 07.04.2014 / 01:08

4 answers

2

Use empty :

if(empty($variavel)) { ...

It returns true for both empty and empty arrays.

    
07.04.2014 / 01:11
1

When using implode in an empty array it will give 1 because the array starts at position 0 then you have to decrease 1 of the variable q count the size of the array

    
07.04.2014 / 03:15
0
if(strlen($variavel) > 0)

It will check how many characters the string has passed, if it is greater than 0, it is because it has something

But several can be used:

if(!isset($variavel))
if($variavel != "")
if($variavel != NULL)
if($variavel[1]) - uma string pode ser usada como array sem ter que fazer ela ser um array
    
07.04.2014 / 02:28
0

Use the strlen ( link ) to find out if the string is greater than 0.

The isset will only tell if the variable was started, which in this case was, however, started empty.

Abs

    
07.04.2014 / 03:08