Jump to content

this code wont work in a function?


followInTo

Recommended Posts

This is reading a txt base database

 

The code works outside a function but not inside. I'm not sure why, if someone can help alter the coding or tell me an answer, that'd be great!

 

function getTheStuff($usname) {
//Begin Pre coding
if ($handle = opendir('db/us/')) {
	while (false !== ($file = readdir($handle))) { 
		if ($file != "." && $file != "..") {

		$file = eregi_replace(".php", "", $file);
		$file = array($file);
			foreach($file as $listed) {
				$item3 = file("db/us/".$listed.".php");
				foreach ($item3 as $item4) {
					list($rusername,$rpassword,$rpoints) = explode ("|^|", $item4);
				}
				// put all members into an array
				$allmembers[] = $rpoints."|^|".$rusername."|^|x|^|";

			}

		} 
	}
	closedir($handle); 
}

// Begin to return data


asort($allmembers);
$count = 0;
	foreach($allmembers as $item) {
		++$count;
		list($pointsxx,$usernamexx) = explode("|^|",$item);
		if($usernamexx == $usname) {
			return $count;
		}
	}
}

Link to comment
https://forums.phpfreaks.com/topic/43062-this-code-wont-work-in-a-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.