Jump to content

[SOLVED] Array Issue


tigomark

Recommended Posts

Hello,

 

I'm having with one of my arrays having a zero value and I'm not sure why

 

This is the array

$this->color[] = "#ff0000";
$this->color[] = "#0000ff";
$this->color[] = "#00ff00";
$this->color[] = "#FF6600";
$this->color[] = "#CC00CC";
$this->color[] = "#EDDC34";
$this->color[] = "#FFCC00";
$this->color[] = "#CC66CC";
$this->color[] = "#CC9999";
$this->color[] = "#CDDF60";
$this->color[] = "#44e2f1";
$this->color[] = "#33FFCC";

for ($i=0; $i<=11; $i++){
$this->zoneColors =  $this->color[$i];
//var_dump($this->zoneColors);	
}
$this->zoneColors = "#ffffff";	


 

Here is the row values from the query

 

    $this->zone1_id = $row['zone1_id'];
    $this->zone2_id = $row['zone2_id'];
    $this->zone3_id = $row['zone3_id'];
    $this->zone4_id = $row['zone4_id'];
    $this->zone5_id = $row['zone5_id'];
    $this->zone6_id = $row['zone6_id'];
    $this->zone7_id = $row['zone7_id'];
    $this->zone8_id = $row['zone8_id'];
    $this->zone9_id = $row['zone9_id'];
    $this->zone10_id = $row['zone10_id'];
    $this->zone11_id = $row['zone11_id'];

 

Here is the view population

 

$reporthtml .= sprintf("<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td>
<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td>
<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td>
<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td>
<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td>
<td bgcolor=\"%s\" title=\"%s - %s\" >
</td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\">
</td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td>
<td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td>
<td bgcolor=\"%s\" title=\"%s - %s\"></td></tr>\n",
    $entry->inspType,
    $entry->assetName,
  	$entry->inspID,
  	$entry->operator,
  	$entry->date,
  	$this->zoneColors[$entry->zone1_id],
  	$entry->zonename1,
   	$entry->timestamp1,
   	$this->zoneColors[$entry->zone2_id],
   	$entry->zonename2,
   	$entry->timestamp2,
   	$this->zoneColors[$entry->zone3_id],
   	$entry->zonename3,
   	$entry->timestamp3,
   	$this->zoneColors[$entry->zone4_id],
   	$entry->zonename4,
   	$entry->timestamp4,
   	$this->zoneColors[$entry->zone5_id],
   	$entry->zonename5,
   	$entry->timestamp5,
   	$this->zoneColors[$entry->zone6_id],
   	$entry->zonename6,
   	$entry->timestamp6,
   	$this->zoneColors[$entry->zone7_id],
   	$entry->zonename7,
   	$entry->timestamp7,
   	$this->zoneColors[$entry->zone8_id],
   	$entry->zonename8,
   	$entry->timestamp8,
   	$this->zoneColors[$entry->zone9_id],
   	$entry->zonename9,
   	$entry->timestamp9,
   	$this->zoneColors[$entry->zone10_id],
   	$entry->zonename10,
   	$entry->timestamp10,
   	$this->zoneColors[$entry->zone11_id],
   	$entry->zonename11,
   	$entry->timestamp11);

 

Now if I do a var_dump of the values I get values until I get to the point where they are populated. At that point I get a null value.

 

Any one got any ideas

Link to comment
Share on other sites

Can you try this out:

 

	for ($i=0; $i<=11; $i++){
$this->zoneColors[$i+1] =  $this->color[$i];
//var_dump($this->zoneColors);	
}
$this->zoneColors[$i+1] = "#ffffff";	

 

The final #ffffff will be assigned to element 12 of the array.  The first 11 values (from $this->color) will be assigned to elements 1-11 of the array.  Is that what you're looking for?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.