|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
array and foreach
I am having trouble. Ihave a form with textarea fact1...fact25 I have an array $fact="array($fact1,...$fact23)" I try to call the array by
foreach($fact as $value){echo <li>$value<p>} in a string. The idea is to make a ordered list of varaibles that are used and not number variables that are not used. Can anyone help? |
|
#2
|
|||
|
|||
|
RE: array and foreach
Code:
foreach($fact as $value){
if ($value){
echo "<li>$value<p>";
}
}
|
|
#3
|
|||
|
|||
|
RE: array and foreach
thanks for the reply. Your answer begins to explain the statement to me. But I still can not make this work.
My Code: <?php $fact="array($fact1,$fact2,$fact3,$fact4,$fact5,$fact6,$f act7,$fact8,$fact9,$fact10,$fact11,$fact12,$fact13 ,$fact14, $fact15,$fact16,$fact17,$fact18,$fact19,$fact20, $fact21,$fact22,$fact23,$fact24,$fact25)"; //Your Code Here? foreach($fact as $value){if $value{"<li>$value<p>"; } }// $head= "<HTML><HEAD><TITLE>$MOTIONTITLE</title><LINK REL=StyleSheet HREF=http://www.plf.net/motions/form/style.css TYPE=text/css MEDIA=screen,print></head><body background=ffffff text=000000><center><h2>$court <br>$STATE</h2><P><h5>$MARRIAGE</h5><h3> <br><table border=0 cellspacing=0 cellpadding=0 width=100% height=11%><tr> <td> <P> $PLAINTIFF <BR> $PLAINTIFFATTORNEY <br>Attorney,<br> VS.<br>$DEFENDANT <br>$DEFENDANTATTORNEY<br>Attorney<br><td>)<br>)<br>)<br>)<br>)<br>)<br></td> <TD> $CASE <P></table></TR><P>$MOTIONTITLE <P></center><LEFT><h4>"; $body="$JURISDICTION<P><ol>$fact1 //or here//<P>$fact2 <P>$fact3 <P>$fact4 <P>$fact5 <P>$fact6 <P>$fact7 <P>$fact8 <P>$fact9 <P>$fact10 <P>$fact11 <P>$fact12 <P>$fact13 <P>$fact14 <P>$fact15 <P>$fact16 <P>$fact17 <P>$fact18 <P>$fact19 <P>$fact20 <P>$fact21 <P>$fact22 <P>$fact23 <P>$fact24 <P>$fact25 </ol><P><ol>$ARGUMENT1 <P>$ARGUMENT2 <P>$ARGUMENT3 <P>$ARGUMENT4 <P>$ARGUMENT5 <P>$ARGUMENT6 <P>$ARGUMENT7 <P>$ARGUMENT8</ol><P>$PRAYER <P><P><center><table><left>Respectfully Submitted<p><P><P>$signature <br>$ADDRESS<BR>$CITY<BR>$ZIP<br>$email</left></table></center>"; $ser="<P><P.breakhere><h5><CENTER><b>CERTIFICATE OF SERVICE</b><P></CENTER><LEFT><BR>I hereby certify this pleading was served upon all attorneys of record for each of the parties to this action and All parties not represented by counsel in the following manner:<BR>[ ] By delivering a copy to them.<BR>[ ] By leaving a copy at their office with the clerk.<BR>[ ] By leaving a copy at them office with an attorney associated with them.<BR>[ ]By mailing a copy to them as prescribed by law<BR>[ ] By faxing a copy to them.<BR>$DATE<P><P><P>So certified:_____________________________<p>$signature<P>"; $hear="<P><CENTER><b>NOTICE OF HEARING<P></b></CENTER><LEFT>The foregoing pleading will be called for hearing before the court on $fDATE at 1 pm or as soon thereafter as petitioner may be heard. So noticed:<p><p><p>_______________________________<p>$signature<P></LEFT>"; echo "$head"; $body=stripslashes($body); echo "$body "; echo "$ser "; echo "$hear "; function cform($motion) { echo $motion="$head.$body.$ser.$hear"; } $to = "$email,lee@plf.net,$clerkemail,$ADemail"; $subject = "Your Motion in Html Save Load in Browser"; $message .= "$head.$body.$ser.$hear"; $header .= "From: PLFrn"; $header .= "Reply-To: ".$email."rn"; $header .= "MIME-Version: 1.0rn"; $header .= "Content-Type: text/html; charset=iso-8859-1rn"; $header .= "X-Priority: 1rn"; $header .= "X-Mailer: PHP / ".phpversion()."rn"; $header .= "Cc: ".$clerkemail."rn"; $header .= "Bcc: ".$ADemail."rn"; mail($to, $subject, $message, $headers); |
|
#4
|
|||
|
|||
|
RE: array and foreach
You've got some errors.
To form an array: $fact=array($fact1,$fact2); Not: $fact="array($fact1,$fact2)"; Also, you were missing the parentheses in the 'if' conditional that I wrote. Here's where you should put that foreach: Code:
$body="$JURISDICTION<P><ol>";
foreach($fact as $value){if ($value) {$body.="<li>$value<p>";}}
$body.="</ol><P><ol>$ARGUMENT1 <P>$ARGUMENT2 <P>$ARGUMENT3 <P>$ARGUMENT4 <P>$ARGUMENT5 <P>$ARGUMENT6 <P>$ARGUMENT7 <P>$ARGUMENT8</ol><P>$PRAYER <P><P><center><table><left>Respectfully Submitted<p><P><P>$signature <br>$ADDRESS<BR>$CITY<BR>$ZIP<br>$email</left></table></center>";
Further: You've got some bad coding habits. I'd read a bunch of PHP tutorials for beginners or get a book before continuing. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > array and foreach |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|