Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
preg_split Offset Warning...
Old 05-25-2006, 12:56 PM preg_split Offset Warning...
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I'm using the following function to decode an encoded session string from a db (function found on php.net). I'm recieving a warning (not fatal) "Notice: Undefined offset: 10 in c:\_localhost . . ." on the same line number of where preg_split() is.

Apache/1.3.33 (Win32) PHP/4.3.10


PHP Code:
function unserializesession($data) {
  
$vars preg_split('/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\|/'$data, -1PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE);
  for(
$i=0$vars[$i]; $i++) {
    
$result[$vars[$i++]] = unserialize($vars[$i]);    
  }
  return 
$result;

__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-26-2006, 04:48 AM Re: preg_split Offset Warning...
Experienced Talker

Posts: 31
Trades: 0
its good practice to debug scripts that still run but throw errors, kudos.

you dont need to write

PHP Code:
$result[$vars[$i++]]; 

just write
PHP Code:
$result[$vars[]]; 
the offset notice is being thrown because
there are keys being used in " unserialize($vars[$i]); " that dont exist in that array

.:origin:. is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to preg_split Offset Warning...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16908 seconds with 12 queries