Jump to content

count / array funtion


pquery

Recommended Posts

Hi,

I'm enhancing the program I've been working on and have received some help on these boards *thanks so far*

 

What I'm trying to do now is add some extra lines, but not too many, so I'm trying to take all the extra lines which are generated and then place them in an array, then count the number which have been totaled up and then spit out a random number (3 probablly) here is my function code so far. You'll notice that I have some echo statements in there so I know what's going on and how many have been inserted.

 

Thanks for any help in advance.

 

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
           +                                 extraLines function                                                              + 
 +    this function comes up with a line for your profile based on some of the  +
 +    extra questions to fill some last lines on the 2nd for part of the Profile    +
 +                                               Globals used                                                            +
 + gender | neady | smallRand | bodyMatter | bodyPref |maintenance|myMood +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function extraLines()
{
     global $gender;
 global $neady;
 global $smallRand;
 global $bodyMatter;
 global $bodyPref;
 global $maintenance;
 global $myMood;
 global $looking;

 $e=0; // counter for number of extra lines produced
 $body = 4;   // counter for body options minus one for array 
 $bc = 0; // counter for the body choices selected 
 $extraHolder; // = array("","","","","","","","","",""); array to hold extra lines created 
 $array = $extraHolder;
 //$insert = 0;
 $insert = "nothing to enter";
 $position = 1;


   if ($bodyMatter == "yes")
   {
     //echo ("<li>I like a $looking who's ");
     $c = count($bodyPref);// counter
     $counter = $c;
     foreach($bodyPref as $bp) 
     {
	  if ($c > 1) 		  
	  { 
		$counter--;
		if ($counter > 0) 
		{ 
			if (!is_null($bp)) 
			{
				echo ("$bp,  ");
			}
		}else{
			echo ("or $bpf ");
			$e++;
			array_insert(&$array, $insert, $position = -1);
			$position++;
		} 
	  }
	  elseif ($c == 1)
	   {
		  foreach($bodyPref as $bp) 
			{
		        if (!is_null($bp)) 
                {

					if($looking == "girl")
					 {
					   $bodytype = $bp;
                            switch ($bodytype)
						{
                          case "thin":
	                      $insert = ("<li>I like a $looking who's Slender and curvy</li>");
	                      break;	
						  case "average":
	                      $insert = "<li>I like a $looking who's Correctly Proportioned</li>";
	                      break;
						  case "thick":
	                      $insert = "<li>I like a $looking who's Luscious....</li>";
	                      break;
						  case "hardbody":
	                      $insert = "<li>I like a $looking who's Tight & Kickin!</li>";
	                      break;
						}
					  array_insert(&$array, $insert, $position = -1);
					  //echo("$bodylike");
					  $e++;
					  $position++;
					  }
                        elseif($looking =="guy")
                        {
                       		$bodytype = $bp;
                            switch ($bodytype)
						{
                          case "thin":
                              $insert = "<li>I like a $looking who's Thin and wirey</li>";
	                      break;	//A slender yet toned body
						  case "average":
	                      $insert = "<li>I like a $looking who's got enought meat to cover those bones</li>";
	                      break;
						  case "thick":
	                      $insert = "<li>I like a $looking who's a big thick teddy bear</li>";
	                      break;
						  case "hardbody":
	                      $insert = "<li> I like a $looking who's chiseled like a statue</li>";
	                      break;
					    }
					  array_insert(&$array, $insert, $position = -1);
					  //echo("$bodylike");
					  $e++;
					  $position++;
					}						
				}
			}
	        

	    }            
       }
        }	
   
  if($bodyMatter == "no")
   {  }

	if($neady == "yes")
	{	}
	elseif($neady == "no")
	{
	  $insert = "<li> I'm your rock to lean on </li>";
	  $e++;
	  array_insert(&$array, $insert, $position = -1);
	  $position++;
	  
	}else{
	     $insert = "<li> I can deal with a needy person </li>";
		  $e++;
		  array_insert(&$array, $insert, $position = -1);
		  $position++;
		 }

	switch ($maintenance)
	{
        case "high":
	    $insert = "<li>Somebody that puts the time into their appearance</li>";
		$e++;
		//array_insert(&$array, $insert, $position = -1)
	    break;	
		case "ave":
	    $insert = "<li>Not super high maintenance please (some maintenance is fine and even appreciated)</li>";
		$e++;
		//array_insert(&$array, $insert, $position = -1);
	    break;
		case "low":
	    //echo("<li>low maintenance</li>");
		//$e++;
	    break;
	}
	$eArray = $e; // creating an array to hold the random number created so duplicated

	 // $rande = (1,$eArray);
	  //check against any numbers in the array
	//foreach ($e as $extra)

foreach($array as $a) 
{
	if ($e > 1) //updated
	{
		$eArray--;
		if ($eArray > 0) // I think this is where some of the problem is 
		{ 
			if (!is_null($a)) 
			{
				echo ("$a[$e]");
			}
		}else{
			echo ("Last line: $a[$e] ");
		} 
	}elseif ($e == 1){
	    echo ("$a  only one line");
        }
   }
        echo ("<br>Body type count (c) = $c");
    echo ("<br>Number of Extra lines after = $eArray");
	echo ("<br>Number of Extra lines produced = $e");
        //echo ("<br> Body count = $bc");			

   
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.