Jump to content


Photo

create_function


  • Please log in to reply
1 reply to this topic

#1 sjade1

sjade1
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 03 June 2006 - 07:26 PM

I'm trying to create a function to take care of explode

$characterExploder = create_function('$a', 'return list($cName, $cImage, $cDescription) = explode("|",$a);');

$data = "Jack|picture.jpg|about Jack";

$characterExploder($data);
echo"
1: $cName<br>
2: $cImage<br>
3: $cDescription";

Returns:
1:
2:
3:

They're all blank...not sure why..?
Any help would be appreciated, thank you.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 03 June 2006 - 08:05 PM

Variable scope.

Variables created inside a function are local to that function and not available outside it.

[a href=\"http://us3.php.net/manual/en/language.variables.scope.php\" target=\"_blank\"]http://us3.php.net/manual/en/language.variables.scope.php[/a]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users