note 105576 deleted from function.get-declared-classes by danbrown

From: Date: Mon, 29 Aug 2011 18:19:06 +0000
Subject: note 105576 deleted from function.get-declared-classes by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182813@lists.php.net to get a copy of this message
Note Submitter: php dot net at bordeux dot net ---- <?php class xv_test { public function test (){ return "test"; } } class xv_example { public function test (){ return "test"; } } function get_declared_classes_by_prefix($prefix = ""){ $result = array(); foreach(get_declared_classes() as $class) if($prefix == substr($class, 0, strlen($prefix))) $result[] = $class; return $result; } var_dump(get_declared_classes_by_prefix("xv_")); /* result is array 0 => string 'xv_test' (length=7) 1 => string 'xv_example' (length=10) */ ?> Search class by prefix.

« previous php.notes (#182813) next »