Created
October 3, 2011 16:02
-
-
Save freretuc/1259459 to your computer and use it in GitHub Desktop.
Delete empty array element (with sort)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre><?php | |
$arr[] = "b"; | |
$arr[] = ""; | |
$arr[] = "aa"; | |
$arr[] = "c"; | |
$arr[] = ""; | |
$arr[] = "da"; | |
print_r($arr); | |
sort($arr); | |
print_r($arr); | |
while(trim($arr[0]) == '' && count($arr) > 0) { | |
array_shift($arr); | |
} | |
print_r($arr); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment