str_replace()
AgentX - 22/06/2006 18:56
|
HTML beginner |
|
Ik krijg helemaal geen output...
Hoe kan ik dit werkende krijgen??
<?php
function encrypt($lol){
$lol = "lollos";
$msg = str_replace("a","n", $lol);
$msg = str_replace("b","o", $lol);
$msg = str_replace("c","p", $lol);
$msg = str_replace("d","q", $lol);
$msg = str_replace("e","r", $lol);
$msg = str_replace("f","s", $lol);
$msg = str_replace("g","t", $lol);
$msg = str_replace("h","s", $lol);
$msg = str_replace("i","u", $lol);
$msg = str_replace("j","v", $lol);
$msg = str_replace("k","w", $lol);
$msg = str_replace("l","x", $lol);
$msg = str_replace("m","y", $lol);
$msg = str_replace("n","z", $lol);
}
echo encrypt(nl2br($lol));
exit();
?>
<?php function encrypt($lol){ $lol = "lollos"; } ?>
|
4 antwoorden
Gesponsorde links |
|
Rens - 22/06/2006 19:01
|
Crew algemeen |
|
Je moet je bericht nog 'terugsturen':
$msg = str_replace("n","z", $lol);
return $msg;
}
echo encrypt(nl2br($lol));
exit();
?>
|
Simon - 22/06/2006 19:02
|
PHP expert |
|
<?php
function encrypt($lol){
$msg = str_replace("a","n", $lol);
$msg = str_replace("b","o", $lol);
$msg = str_replace("c","p", $lol);
$msg = str_replace("d","q", $lol);
$msg = str_replace("e","r", $lol);
$msg = str_replace("f","s", $lol);
$msg = str_replace("g","t", $lol);
$msg = str_replace("h","s", $lol);
$msg = str_replace("i","u", $lol);
$msg = str_replace("j","v", $lol);
$msg = str_replace("k","w", $lol);
$msg = str_replace("l","x", $lol);
$msg = str_replace("m","y", $lol);
$msg = str_replace("n","z", $lol);
return $msg;
}
$lol = "lollos";
echo encrypt(nl2br($lol));
exit();
?>
<?php function encrypt($lol){ return $msg; } $lol = "lollos"; ?>
|
AgentX - 22/06/2006 19:06
|
HTML beginner |
|
Je moet je bericht nog 'terugsturen'
Je moet je bericht nog 'terugsturen'
Ja natuurlijk, das waar!
het werkt, bedankt voor de hulp! |
nemesiskoen - 22/06/2006 19:12
|
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"
<?php
function encrypt($msg){
$msg = str_replace("a","n", $msg);
$msg = str_replace("b","o", $msg);
$msg = str_replace("c","p", $msg);
$msg = str_replace("d","q", $msg);
$msg = str_replace("e","r", $msg);
$msg = str_replace("f","s", $msg);
$msg = str_replace("g","t", $msg);
$msg = str_replace("h","s", $msg);
$msg = str_replace("i","u", $msg);
$msg = str_replace("j","v", $msg);
$msg = str_replace("k","w", $msg);
$msg = str_replace("l","x", $msg);
$msg = str_replace("m","y", $msg);
$msg = str_replace("n","z", $msg);
return $msg;
}
echo encrypt(nl2br("banaan"));
echo "<br />";
echo encrypt(nl2br("baaaan"));
echo "<br />";
echo encrypt(nl2br("bnnnnn"));
echo "<br />";
echo encrypt(nl2br("baaaaa"));
echo "<br />";
echo encrypt(nl2br("bnnnan"));
echo "<br />";
?>
<?php function encrypt($msg){ return $msg; } ?>
:
ozzzzz
ozzzzz
ozzzzz
ozzzzz
ozzzzz
Niet echt omkeerbaar dunkt me. |
Gesponsorde links |
|
Dit onderwerp is gesloten. |
|