I want to count the total number of element of an array.But my problem is that when i am counting the element of array using count() or sizeof() function then its also count that index which value is empty .
My array is below :--
Happy coding guys :)
My array is below :--
Array([search_type] => both[keywordname] =>[keywordlname] =>[keywordemail] =>[keywordphone] =>[keywordfax] =>[keywordnote] => testing[keyworddocument] =>[keywordtask] =>[keywordcity] =>[keywordstate] =>[keywordzipcode] =>[keywordcountry] =>[keywordcorporate] =>[keyworddirector1] =>[keyworddirector2] =>[keywordstatefiled] =>[keywordentity] =>[keywordfromtime] =>[keywordtotime] =>)
In the above array i want to count that only which value is not empty.
So i want to result 2.
echo "Count is ".count(array_filter($array));
Description : array_filter() will get only that array keys and values which
are not empty.Now i am using count() to count the array element.
If you like this post please don't forgot to notify me to post a comment .Happy coding guys :)