$arr = explode("/","//a");
why do i get 2 empty cells before "a" in my array?
$arr[0] == ""
$arr[1] == ""
$arr[2] == "a"
count($arr) == 3
what i'd expect is
$arr[0] == "a"
count($arr) == 0
not sure about the php version, phpinfo is blocked and i have no control over the server - i do know it's oldish
variation of string::explode() that works?
Moderator: General Moderators
Re: variation of string::explode() that works?
do array_filter(explode('/', '//a'));
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: variation of string::explode() that works?
that does half the job
i've got an array with count() of 1 like expected, but the value "a" is in cell [2]
i could grab the count()-1 from before the array_filter and use that to point to the value afterwards, but that seems a bit contrived...
i've got an array with count() of 1 like expected, but the value "a" is in cell [2]
i could grab the count()-1 from before the array_filter and use that to point to the value afterwards, but that seems a bit contrived...
Re: variation of string::explode() that works?
This is starting to feel ugly, lol... but..
array_values(array_filter(explode('/', '//a')));
array_values(array_filter(explode('/', '//a')));
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: variation of string::explode() that works?
thanks that seems to work... ugly tho' it may be 
Re: variation of string::explode() that works?
Code: Select all
$arr = preg_split("#/#","//a", -1, PREG_SPLIT_NO_EMPTY);
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: variation of string::explode() that works?
Your example is simplistic so I don't know what other inputs you'll have, but strtok() might be of use.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.