0
   

how to set null array values to 0?

 
 
Fri 10 Jun, 2016 06:48 am
[Moderator note: Content of question copied verbatim from http://stackoverflow.com/questions/37746349/making-null-array-values-set-to-0 has been removed]
What is the error present in the code?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 723 • Replies: 6
Topic Closed

 
engineer
 
  3  
Fri 10 Jun, 2016 06:55 am
@channing tactum,
channing tactum wrote:

if($element == "")
{
$firstbloodkill[$key] = 0;
}

Shouldn't it be

Quote:
if($firstbloodkill[$key] == "")
websitedesigns
 
  2  
Fri 10 Jun, 2016 07:07 am
@engineer,
[Moderator note: Content of answer copied verbatim from http://stackoverflow.com/questions/37746349/making-null-array-values-set-to-0 has been removed]
This code will help you to solve your problem
DrewDad
 
  1  
Fri 10 Jun, 2016 09:26 am
@channing tactum,
Try using if (empty($element)) and/or if(!isset($element)) instead of if($element == "").

https://stackoverflow.com/questions/5615747/what-is-the-difference-between-null-and-empty
channing tactum
 
  2  
Fri 10 Jun, 2016 11:38 pm
@DrewDad,
it worked
0 Replies
 
channing tactum
 
  2  
Fri 10 Jun, 2016 11:41 pm
@websitedesigns,
ya it worked,thanks.
0 Replies
 
Jay2know
 
  0  
Tue 21 Jun, 2016 09:41 pm
Have you ever felt your freedom of speech has just been squelched? lol
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » how to set null array values to 0?
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/25/2024 at 06:31:03