Troublesome callbackfunction

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tores
Forum Contributor
Posts: 120
Joined: Fri Jun 18, 2004 3:04 am

Troublesome callbackfunction

Post by tores »

Hi

Can someone tell me why $serie is unset in the callback-function hentSerie?

Code: Select all

<?php
  /* Other function */
  $serie = "A";
  $Aserie = array_filter($identifikatorer, "hentSerie");

/* Callback function */
function hentSerie($element){
  global $serie;
  return ($serie == $element{0});
}

?>
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Seems to work for me.

Code: Select all

$identifikatorer:
array(3) &#123;
  &#1111;0]=>
  string(5) "A car"
  &#1111;1]=>
  string(4) "boat"
  &#1111;2]=>
  string(7) "A house"
&#125;

$Aserie:
array(2) &#123;
  &#1111;0]=>
  string(5) "A car"
  &#1111;2]=>
  string(7) "A house"
&#125;
Post Reply