3 Replies - 3544 Views - Last Post: 23 July 2012 - 12:54 PM Rate Topic: -----

#1 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Question: What does undefined offset mean?

Posted 23 July 2012 - 12:32 PM

Hello,
I have a quick question. What does undefined offset mean? I have looked around on the net and I can't find a definite answer as to what the error means. With that said, I am getting the notice 8 undefined offset error and I don't know how to troubleshoot it. Here is some of my code. My errors are on lines 10-18. Any input would be greatly appreciated.


 <?php 
class CoverageExcelAdapter {

	public function extract($s, $args = array()) { 
		App::import('component', 'CakeSession');        
		$userId = CakeSession::read('Auth.User.id');		
		$ret = array();

		$ret['Coverage'] = array(
			'name' => $s[0][12][3], 
			'effective_date' => $this->Date->formatDate($s[0][18][3]),
			'expiration_date' => $this->Date->formatDate($s[0][18][6]),
			'broker_first_name' => ucwords($s[0][23][3]),
			'broker_middle_initial' => strtoupper(substr($s[0][24][3], 0, 1)),
			'broker_last_name' => ucwords($s[0][25][3]),
			'broker_suffix' => ucwords($s[0][26][3]),
			'producing_id' => $this->State->stateStrToId($s[0][14][3]), 
			'filing_id' => $this->State->stateStrToId($s[0][14][6]),




Is This A Good Question/Topic? 0
  • +

Replies To: Question: What does undefined offset mean?

#2 jared.deckard  Icon User is offline

  • New D.I.C Head

Reputation: 18
  • View blog
  • Posts: 46
  • Joined: 11-July 12

Re: Question: What does undefined offset mean?

Posted 23 July 2012 - 12:41 PM

It sounds like $s is null.

You should ensure $s is not null at the beginning of the function or before you make the function call.
Was This Post Helpful? 0
  • +
  • -

#3 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: Question: What does undefined offset mean?

Posted 23 July 2012 - 12:49 PM

Ok correct me if Im wrong but does undefined offset mean that my array is undefined?
Was This Post Helpful? 0
  • +
  • -

#4 jared.deckard  Icon User is offline

  • New D.I.C Head

Reputation: 18
  • View blog
  • Posts: 46
  • Joined: 11-July 12

Re: Question: What does undefined offset mean?

Posted 23 July 2012 - 12:54 PM

No, but it does mean that the [number] you are trying to access is not defined. Trying to access $s[4] if $s only has 3 elements will throw this error. It will also throw the error if $s has 0 elements (null).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1