Novice question
| From: | brendan conroy | Date: | Sat, 23 Feb 2002 17:12:31 +0000 |
| Subject: | Novice question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85943@lists.php.net to get a copy of this message | ||
Hi,
thanks for reading this, Im just going to say it cos i dont want to waste your time. Im looking for a really big favour here(cos I think it may take time to spot this, although it might only take five seconds to spot, but I dunno,the problem area of code is only four lines long), so dont spend time reading this unless you got half an hour spare or are looking a good samaritan award or something.
Still reading this? Excellent, Iam saved.
I wrote code which takes a input string, breaks it up and puts the bits into an array called $real. THIS WORKS.
But I may have lots of input strings so I slapped a for loop around the code to do the same thing for all the inputs and THAT WORKS ASWELL!
Then i wanted to save the different bits of each input string in its own array, so I created an array of arrays and at the end of each cycle of the big loop, I take out all the element in $real and put them into the array of arrays, called $poly[][]. THIS DOESNT WORK.
I've spent a week trying to fix this and get that horrible feeling that all the work is going down the drain, cos if I dont get this working, I am screwed.
I'd be sincerely grateful if someone could help me with this
/*===========================*/
I put these type of comments around the problem area of the code, which is about four lines long near the bottom
/*===========================*/
Regards
Bren
<html>
<body>
<?
print_r($poly);
echo"<HR>";
$real[0]=0;
$z=array_pop($real);
$array[0] = 0;
$z = array_pop($array);
/*$real[0] = 0;
$z = array_pop($real);*/
$test[0]=0;
$z = array_pop($test);
/*big loop=============================================*/
for($ws=0;$ws<count($poly);$ws++)
{
$rt=0;
$c = explode("+", $poly[$ws]);
/*echo"C EQUALS"."<BR>".*/
/*echo"shit";
print_r($c);*/
for($r=0;$r<=count($c);$r++)
{
/* echo"peaches";
echo"<HR>";*/
$m=$c[$r]; echo"M EQUALS"."<BR>";echo"$m";
echo"<BR>";
$count=0;
for($j=0;$j<strlen($m);$j++)
{
/* echo"purple";*/
/* echo"$c[$r]";*/
echo"<BR>";
/*$count=0;*/
if($m[$j]=="-" )
{
$count++;
}
}if((($m[0]=="-")AND($count<2))OR($count<1)) { echo"dumbass"; echo"<BR>";
/*if(count($real)<=4)*/
{
array_push($real,$c[$r]);
echo"<BR>";
}
}elseif(($m[0]=="-")AND($count>1)) { echo"blaaaaaaaaaaaaa"; echo"<BR>"; $ss = explode("-",$m); for($cnt=0;$cnt<count($ss);$cnt++) { echo"sweetness"; echo"<BR>"; $ss[$cnt] = "-".$ss[$cnt];
for($waa=0;$waa<count($c);$waa++){ array_push($real,$ss[$cnt]); } } } else { echo"waaweaaawaaaweaaa"; echo"<BR>"; $ss = explode("-",$m);
for($na=1;$na<count($ss);$na++){ $ss[$na] = "-".$ss[$na]; } for($la=0;$la<=count($c);$la++) { array_push($real,$ss[$la]); echo"<BR>"; } } /*echo"$count"; echo"real"; echo"<BR>"; print_r($real); */ } /* for($rt=0;$rt<count($real);$rt++) */ /*=====================heres the problem==================*/ while(count($real)>0) { print_r($real); echo"<BR>"; $poly[$ws][$rt]=array_pop($real); $rt++; echo"pink elephants"; /*========================================================*/ } } /*end of big loop*/ echo"real"; echo"<BR>"; print_r($real); echo"<HR>"."POLY EQUALS"; for($ty=0;$ty<4/*count($poly[$ws][$rt])*/;$ty++) { echo"<HR>"."print loop"; echo $poly[0][$ty]; echo"<HR>"; } echo"<HR>"; ?> </body> </html> _________________________________________________________________ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com