On Wed, 2002-04-10 at 15:01, Erik Price wrote: > Hi everyone. I'm really banging my head against this one. Everything > seems to be working, but this constructor method doesn't seem to want to > pass. The error message I am getting is "you did not pass the > preg_match()", so I'm clearly not passing the preg_match(). But I can't > figure out why.
Your regex is fine. The problem is a fencepost error in your for() loop; you're going past the end of your folder list. > // constructor, transforms a form field value into a file ID > // which will be accepted by set_file_id() > function FolderFile($value) > { > if (preg_match('/^folderfile\d+$/', $value)) { > // transform the form field value into an acceptable > // format for set_file_id() method (below) //put an echo here to show when you succeed: echo "passed the test with $value\n"; > $value = str_replace("folderfile", "", $value); > if (!$this->set_file_id($value)) { > die("you passed the preg_match() but not > the set_file_id() method"); > return false; > } else { > return true; > } > } else { > die("you did not pass the preg_match()"); > return false; > } > > } > > The code itself, which constructs this instance and calls the > constructor method, is this: > > // $_GET['addtofolder'][0] = "folderfile1"; > // $_GET['addtofolder'][1] = "folderfile2"; > for ($i = 0; $i <= count($_GET['addtofolder']); $i++) { ^^ This will go from 0 to 2, when you only want it to go from 0 to 1. Replace <= with < and it should work for you. Better yet, use a foreach() ;) Cheers, Torben > $ff_instance = new FolderFile($_GET['addtofolder'][$i]); > > $folderfile_list[] = $ff_instance->show_name(); > unset($ff_instance); > } > > So, I'm passing the constructor a value of "folderfile1", but that > doesn't seem to work with my preg_match() (above). Yet it seems like it > should work fine. Can anyone see what I'm doing wrong here? > > > Thank you, > > Erik -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php