Page 1 of 1

Function Declaration Problem

Posted: Fri May 06, 2005 2:09 am
by bluenote
Hi there,

i have a possibly easy-to-solve problem :roll:

The goal of the following code:

Code: Select all

if (($navpath_puma === false) && ($navpath_puma_verwaltung === false) && ($navpath_puma_verwaltung01 === false) && ($navpath_puma_verwaltung02 === false) && ($navpath_puma_verwaltung03 === false) && ($navpath_puma_export === false) && ($navpath_puma_listen01 === false) && ($navpath_puma_listen02 === false) && ($navpath_puma_listen03 === false) && ($navpath_puma_listen04 === false) && ($navpath_puma_listen05 === false) && ($navpath_puma_loeschen01 === false) && ($navpath_puma_loeschen02 === false) && ($navpath_puma_loeschen03 === false) && ($navpath_puma_loeschen04 === false) && ($navpath_puma_eingabe01 === false) && ($navpath_puma_eingabe02 === false) && ($navpath_puma_eingabe03 === false) && ($navpath_puma_eingabe04 === false) && ($navpath_puma_eingabe05 === false) && ($navpath_puma_aenderung01 === false) && ($navpath_puma_aenderung02 === false) && ($navpath_puma_aenderung03 === false) && ($navpath_puma_aenderung04 === false) && ($navpath_puma_aenderung05 === false)) {}

else {

	$initials = $_REQUEST["initials_$i"];

	$string1 = trim($initials);
	$string2 = str_replace(" ","","$string1");

	$charReplace = array (

	"."=>"",
	","=>"",
	";"=>"",
	":"=>"",
	"0"=>"",
	"1"=>"",
	"2"=>"",
	"3"=>"",
	"4"=>"",
	"5"=>"",
	"6"=>"",
	"7"=>"",
	"8"=>"",
	"9"=>"",
	"@"=>"",
	"!"=>"",
	"ยง"=>"",
	"$"=>"",
	"%"=>"",
	"&"=>"",
	"/"=>"",
	"("=>"",
	")"=>"",
	"="=>"",
	"?"=>"",
	"+"=>"",
	"*"=>"",
	"~"=>"",
	"#"=>"",
	"'"=>"",
	"_"=>"",
	"^"=>"",
	"<"=>"",
	">"=>"",
	"|"=>"");

	$string3 = strtr($string2,$charReplace);
	$string4 = strtoupper($string3);
	$length = strlen("$string4");

	if ($length > '0') {

		if ($length=='1') {

			$string8 = "$string4.";}

			else if ($length >= '2') {

				function text($string4,$limit=2,$chop=2) {

					$text = explode(" ",$string4);

					while (list($key, $value) = each($text)) {

						$flength = strlen($value);

						if ($flength >= 2){

							for ($f=0;$f<=$flength;$f+=1) {

								$new .= substr($value, $f, 1);

								$new .= ". ";}

								$post = $new;}

								else if ($flength < 2){

									$post .= $value;}

									$post .= ". ";}

									return($post);}

									$output = text("$string4", 10, 5);

									$subcount1 = $length;
									$subcount2 = $length + $length;
									$subcount3 = $length - 1;
									$count = $subcount2 +  $subcount3;

									$string7 = substr($output, 0, $count);
									$string8 = str_replace(". -. ",".-","$string7");}

									global $string8;}

									$string10 = strlen("$string8");
									$string11 = strrpos($string8, ".");
									$string12 = $string11 + 1;

									if ($string10 === $string12) {

										$initials = "$string8";}

										else {

											$initials = "$string8.";}}
is to clean up the mess some users are putting in the forms (here especially in the name fields) of our web reference manager. The initials have to be very very clean - for example: Myers, A. F. G. (ntoce the dots and whitespaces) AND NOT afg. or A.FG or something else. The code itself is working, that's not the problem. But: one reference may has 13 authors, so i have to perform this 13 times, and if the first checkk passed,

Code: Select all

&#1111;Fri May  6 08:56:41 2005] &#1111;error] PHP Fatal error:  Cannot redeclare text() (previously declared in /usr/local/lib/BLUErdb/include/libraries/puma_51.lib:65) in /usr/local/lib/BLUErdb/include/libraries/puma_51.lib on line 65
Any ideas?

Greez and TIA,
- bluenote

Posted: Fri May 06, 2005 5:18 am
by andre_c
just take the text() function out of the conditional statements and make sure to do require_once() or include_once if you're including this file somewhere else