Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list/split & undefined offset

Status
Not open for further replies.

Moooink

Technical User
Feb 22, 2002
48
0
0
US
Can someone explain to me the reason the list/split functions give an Undefined offset error?

PHP Notice: Undefined offset: 1 in C:\ on line 22

and line 22 is:

list ($i, $j) = split ("[/]", $id);
 
$a=split ("[/]", $id);

does this work?


Known is handfull, Unknown is worldfull
 
if u dont know how many variables ur goin to get u can make use of method vbkris has mentioned.

Also while retrieving the varibles u will have to parse the array ie $a
foreach ($a as $val) {
...
}

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
split() is a Perl function, isn't it?

Try;

$cut = explode("[/]", $id);
$i = $cut[0];
$j =$cut[1];

Cheers

Andy
 
... which shouldn't be used, as the manual states. Especially not in this case, when you are just splitting on a single character ([tt]/[/tt]).

//Daniel
 
well its a different matter altogether.
I just informed that there is a function called split in php

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top