Venom Posted December 10, 2004 Report Share Posted December 10, 2004 sk. break/continue, exit, die Link to comment Share on other sites More sharing options...
raivis Posted December 10, 2004 Author Report Share Posted December 10, 2004 (edited) nez vai sapratīsiet jautājumu, bet.. Ja data.txt: 03.12.2004|janis|komentārs@07.12.2004 16:35|peter|komentārs1*07.12.2004 19:48|olga|komentārs2*12.12.2004 08:06|janis|komentārs3* 21.10.2004|admin|komentārs@07.11.2004 16:35|peter|komentārs1*07.11.2004 19:48|olga|komentārs2* Kā iespējams šo skriptu attiecināt uz failu data.txt sākot ar simbolu @ $fileData = file('data.txt'); $messageList = array(); foreach ($fileData as $row){ list($date, $user, $msg) = explode('|', $row); $messageList[$user] = array('date' => $date, 'user' => $user, 'msg' => $msg); } ksort($messageList); echo '<h4>Ziņojumi..</h4>'; foreach ($messageList as $key => $message){ echo '<i>'.$message['date'].'</i> <b>'.$message['user'].'</b>: '.$message['msg'] . '<br>---<br>'; } proti, if ($lpp==$rindinja) { print no rindiņas $rindinja mainīgo $message['date'], $message['user'], $message['msg'] vērtības } else { ja nav iepostotu ziņojumu: print "no message"; } proti, gala rezultātā vajadzētu izskatīties kam tml: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 03.12.2004 Janis komentārs [3 komentāri] --- 21.10.2004 Admin komentārs [2 komentāri] --- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Aplūkojot 03.12.2004 datuma komentārus: //?lpp=0 03.12.2004 Janis komentārs ------------------------------------------------------ 12.12.2004 08:06 Janis komentārs3 --- 07.12.2004 19:48 Olga komentārs2 --- 07.12.2004 16:35 Peter komentārs1 --- Pievienot savu komentāru.. Aplūkojot 03.12.2004 datuma komentārus: //?lpp=1 21.10.2004 Admin komentārs ------------------------------------------------------ 07.11.2004 19:48 Peter komentārs2 --- 07.11.2004 16:35 Olga komentārs1 --- Pievienot savu komentāru.. !??? Edited December 13, 2004 by raivis Link to comment Share on other sites More sharing options...
Snukzz Posted December 10, 2004 Report Share Posted December 10, 2004 (edited) nesapratu... ko tu tur meegjini panaakt :ph34r:, DELFI 2 * APOLLO + MSN vai...? Edited December 13, 2004 by Snukzz Link to comment Share on other sites More sharing options...
raivis Posted December 14, 2004 Author Report Share Posted December 14, 2004 !?Nav ne jausmas, kā lai panāku, ka "no info" izvadītu tikai 1reizi, ņemot vērā, ka data.txt: Janis|18|janis@inbox.lv| Peteris|21|peter@mail.com| Juris|51|juris_s@navigator.lv| Olga|18|bebe18@apollo.lv| Janis|11|janitis@fdm.lv| $fileData = file("data.txt"); $personList = array(); foreach ($fileData as $row){ list($name, $age, $email) = explode('|', $row); $personList[] = array('name' => $name, 'age' => $age, 'email' => $email); } echo '<h1>Personas dati</h1>'; foreach ($personList as $key => $person){ if ($person['name'] == 'Peteris'){ continue print '<h2>'.$person['name'].'</h2> <p>Vecums: '.$person['age'].'</p> <p>E-pasts: '.$person['email'].'</p>'; break; } else { continue print "no info"; break; //break; continue; exit; die; } } Link to comment Share on other sites More sharing options...
raivis Posted December 20, 2004 Author Report Share Posted December 20, 2004 ..no jūsu puses: klusums!? $fileData = file("data.txt"); $personList = array(); foreach ($fileData as $row){ list($name, $age, $email) = explode('|', $row); $personList[] = array('name' => $name, 'age' => $age, 'email' => $email); } echo '<h1>Personas dati</h1>'; foreach ($personList as $key => $person){ if ($person['name'] == 'Peteris'){ print '<h2>'.$person['name'].'</h2> <p>Vecums: '.$person['age'].'</p> <p>E-pasts: '.$person['email'].'</p>'; } else { print "no info"; //pat, ja ir vairākas $person['name'] vētības; } else { "no info" izvadīt tikai 1 REIZI!! } } Kā lai pieprasu, lai "no info" izvadītu tikai 1 REIZI!, ja ir vairākas $person['name'] vētības? //ar break; continue; exit; die; nekā nav līdzēts :( Link to comment Share on other sites More sharing options...
raivis Posted December 20, 2004 Author Report Share Posted December 20, 2004 (edited) ..vai tas iespējams :blink: Edited December 20, 2004 by raivis Link to comment Share on other sites More sharing options...
Recommended Posts