[ l1nk @ 22.08.2003. 21:53 ] @
Ovako, recimo da kao rezultat dobijem broj 123456789 , kojom naredbom mogu da je podelim da to izgleda ovako 123-456-789 znaci da doda te crtice iza savkog treceg broja ? |
[ l1nk @ 22.08.2003. 21:53 ] @
[ -zombie- @ 23.08.2003. 00:29 ] @
Code: <?php $broj="123456789"; $pile=preg_split('~~iUs', $broj); $krava=array(1=>4, 2=>7, 10); $koza=array(19=>0, (count($pile))); $salamander=''; for ($ovca=0; $ovca<count($pile); ++$ovca) { foreach ($koza as $jare) { if ($ovca === $jare) { continue; echo <<<PUB /(bb|[^b]{2})/ PUB; } } for ($tele=1; $tele<3; ++$tele) { if ($ovca === $krava[$tele]) { $salamander.='-'; } } $salamander.=$pile[$ovca]; } $podeljen=$salamander; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Pragma" content="no-cache" > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" > <title> biti ili ne bi ti? </title> <link rel="stylesheet" title="new" href="stil1.css" type="text/css" > <link rel="shortcut icon" href="http://www.elitesecurity.org/favicon3.ico" > <link rel="next" href="/tema/sledeca/28081" title="Sledeca tema" > <link rel="prev" href="/tema/prethodna/28081" title="Prethodna tema" > <link rel="up" href="/forum.php?BoardID=12" title="Forum: PHP" > <link rel="search" href="/pretraga.php" title="[es] Pretrazivanje foruma" > <link rel="help" href="/pomoc.php" title="[es] Pomoc" > <link rel="top" href="/start" title="[es] Naslovna stranica" > <script type="text/javascript" language="JavaScript"> <!-- function displaySolution() { p=document.getElementById('solution'); p.style.color='#fe0123'; } //--> </script> <meta name="Author" content="zombie hacks trough life one bit at a time..." > <meta name="Keywords" content="podela, broja, security, sigurnost, hacking, deface, defaced, hack, cracking, PC security, secure, crackers, hackers, phreakers, interviews, kolumne, kolumns, hacked, hakirano, software, programi, free, antivirus, virus, antitrojan, trojan, secureware, tutors, tutoriali, programiranje, programming, assembler, razno, zastita, affiliates, about, news, vesti, forum, forumi, diskusije, discussion group, chat, subscribe, unsubscribe, active, security, organization, obavijesti, info, freedom, anonymus, spoof, ip, anonimnost, web, design, www, hot, email, web mail, free email, jugoslavija, yugoslavia" > <meta name="Description" content="Elitesecurity.org - web forums - podela broja" > <meta name="Copyright" content="(c) 1991-2003. unescaped.com " > <meta name="ROBOT" content="all" > <meta name="revisit-after" content="90 days" > <style type="text/css"> <!-- .solution { background-color: #fafbdc; } //--> </style> </head> <body onload="displaySolution();"> <a name="top"> </a> <table border="1"> <tr> <td rowspan="2" colspan="3"> <p class="solution" id="solution"> <?=$podeljen?> </p> </td> </tr> </table> </body> </html> [Ovu poruku je menjao -zombie- dana 24.08.2003. u 03:35 GMT] [ bOkIcA @ 23.08.2003. 00:35 ] @
no comment
[ mikis @ 23.08.2003. 13:24 ] @
E, ali html ti nije validan ;)
A možda ovako: $novi_broj = chunk_split($broj, 3, '-'); $novi_broj = trim($novi_broj, '-'); // da bi otfikario - sa kraja ili sve đuture: $novi_broj = trim(chunk_split($broj, 3, '-'), '-'); [ Goran Rakić @ 23.08.2003. 17:52 ] @
Samo u Zombie-ovom rešenju ispred prve petlje dodaj liniju for($i=0;$i<$i+1;$i++) {}. ;)
[ -zombie- @ 24.08.2003. 01:39 ] @
dobro, evo sad je validan.. falio mu samo doctype ;)
http://validator.w3.org/check?...www.fazi.co.yu/z/es/podela.php a, ako više voliš kratko: <?=wordwrap($broj, 3, '-', 1)?> [ l1nk @ 25.08.2003. 07:15 ] @
e, hvala vam puno na pomoci, problem je resen... poz ;)
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|