login  Naam:   Wachtwoord: 
Registreer je!
 Forum

str_replace()

Offline AgentX - 22/06/2006 18:56
Avatar van AgentXHTML beginner Ik krijg helemaal geen output...
Hoe kan ik dit werkende krijgen??

  1. <?php
  2. function encrypt($lol){
  3. $lol = "lollos";
  4. $msg = str_replace("a","n", $lol);
  5. $msg = str_replace("b","o", $lol);
  6. $msg = str_replace("c","p", $lol);
  7. $msg = str_replace("d","q", $lol);
  8. $msg = str_replace("e","r", $lol);
  9. $msg = str_replace("f","s", $lol);
  10. $msg = str_replace("g","t", $lol);
  11. $msg = str_replace("h","s", $lol);
  12. $msg = str_replace("i","u", $lol);
  13. $msg = str_replace("j","v", $lol);
  14. $msg = str_replace("k","w", $lol);
  15. $msg = str_replace("l","x", $lol);
  16. $msg = str_replace("m","y", $lol);
  17. $msg = str_replace("n","z", $lol);
  18. }
  19.  
  20. echo encrypt(nl2br($lol));
  21. exit();
  22. ?>

4 antwoorden

Gesponsorde links
Offline Rens - 22/06/2006 19:01
Avatar van Rens Gouden medaille

Crew algemeen
Je moet je bericht nog 'terugsturen':

  1. $msg = str_replace("n","z", $lol);
  2. return $msg;
  3. }
  4.  
  5. echo encrypt(nl2br($lol));
  6. exit();
  7. ?>
Offline Simon - 22/06/2006 19:02
Avatar van Simon PHP expert
  1. <?php
  2. function encrypt($lol){
  3. $msg = str_replace("a","n", $lol);
  4. $msg = str_replace("b","o", $lol);
  5. $msg = str_replace("c","p", $lol);
  6. $msg = str_replace("d","q", $lol);
  7. $msg = str_replace("e","r", $lol);
  8. $msg = str_replace("f","s", $lol);
  9. $msg = str_replace("g","t", $lol);
  10. $msg = str_replace("h","s", $lol);
  11. $msg = str_replace("i","u", $lol);
  12. $msg = str_replace("j","v", $lol);
  13. $msg = str_replace("k","w", $lol);
  14. $msg = str_replace("l","x", $lol);
  15. $msg = str_replace("m","y", $lol);
  16. $msg = str_replace("n","z", $lol);
  17. return $msg;
  18. }
  19. $lol = "lollos";
  20. echo encrypt(nl2br($lol));
  21. exit();
  22. ?>
Offline AgentX - 22/06/2006 19:06
Avatar van AgentX HTML beginner
  1. Je moet je bericht nog 'terugsturen'


Ja natuurlijk, das waar!
het werkt, bedankt voor de hulp!
Offline nemesiskoen - 22/06/2006 19:12
Avatar van nemesiskoen Gouden medaille

PHP expert
Misschien alle $lol's vervangen door $msg. Anders wordt er alleen de n door de z vervangen.

Wat je uiteindelijk wil doen gelijkt heel hard op atbash, alleen ga ik je zeggen dat dit geen encrypt functie zal zijn.


Waarom niet: het is onmogelijk de omgekeerde waarde te vinden:

"banaan"
==>
"ozzzzz"

"baanan"
==>
"ozzzzz"

"baaaan"
==>
"ozzzzz"

"bnnnnn"
==>
"ozzzzz"


  1. <?php
  2. function encrypt($msg){
  3. $msg = str_replace("a","n", $msg);
  4. $msg = str_replace("b","o", $msg);
  5. $msg = str_replace("c","p", $msg);
  6. $msg = str_replace("d","q", $msg);
  7. $msg = str_replace("e","r", $msg);
  8. $msg = str_replace("f","s", $msg);
  9. $msg = str_replace("g","t", $msg);
  10. $msg = str_replace("h","s", $msg);
  11. $msg = str_replace("i","u", $msg);
  12. $msg = str_replace("j","v", $msg);
  13. $msg = str_replace("k","w", $msg);
  14. $msg = str_replace("l","x", $msg);
  15. $msg = str_replace("m","y", $msg);
  16. $msg = str_replace("n","z", $msg);
  17. return $msg;
  18. }
  19.  
  20. echo encrypt(nl2br("banaan"));
  21. echo "<br />";
  22. echo encrypt(nl2br("baaaan"));
  23. echo "<br />";
  24. echo encrypt(nl2br("bnnnnn"));
  25. echo "<br />";
  26. echo encrypt(nl2br("baaaaa"));
  27. echo "<br />";
  28. echo encrypt(nl2br("bnnnan"));
  29. echo "<br />";
  30. ?>

:
ozzzzz
ozzzzz
ozzzzz
ozzzzz
ozzzzz

Niet echt omkeerbaar dunkt me.
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.221s