Do not return the number of counters for a populated array

$arrg = array();
if( str_word_count( $str ) > 1 ) {
    $input_arr = explode(' ', $str);
    die(print_r($input_arr));
    $count = count($input_arr);
    die($count);

The above is part of the function. when I get in, I get;

Array (
    [0] => luke
    [1] => snowden
    [2] => create
    [3] => develop
    [4] => web
    [5] => applications
    [6] => sites
    [7] => alse
    [8] => dab
    [9] => hand
    [10] => design
    [11] => love
    [12] => helping
    [13] => business
    [14] => thrive
    [15] => latest
    [16] => industry
    [17] => developer
    [18] => act
    [19] => designs
    [20] => php
    [21] => mysql
    [22] => jquery
    [23] => ajax
    [24] => xhtml
    [25] => css
    [26] => de
    [27] => montfont
    [28] => award
    [29] => advanced
    [30] => programming
    [31] => taught
    [32] => development
    [33] => years
    [34] => experience
    [35] => topic
    [36] => fully
    [37] => qualified
    [38] => electrician
    [39] => city
    [40] => amp
    [41] => guilds
    [42] => level)

Expected that

run this but nothing returns:

$arrg = array();
if( str_word_count( $str ) > 1 ) {
    $input_arr = explode(' ', $str);
    //die(print_r($input_arr));
    $count = count($input_arr);
    die($count);
+3
source share
6 answers
die($count);

Kills your script with $count(integer) as exit code .

Do you want to:

die((string) $count);

(or comparable.)

+11
source

From http://www.php.net/manual/en/function.exit.php (same as die ()):

If the status is a string, this function prints the status before exiting.

, . 0 254, 255 PHP . 0 .

+5

. , $count , ? , (strval ($ count))?

+2

die() , , .

...: o)

+2

$count? count count . simly do

die(print($count));

, .

+1

Integer (die ). .

0
source

Source: https://habr.com/ru/post/1742418/


All Articles