Messages - RedPillow [ switch to compact view ]

Pages: prev1 [2] 3 4 5 6 7 ... 28next
6
Since I got your attention already, I'll ask if anyone knows, if it is possible in anyway for random <|p> and <|/p> -tags to get insterted into my code.
ALSO, str_replace wont find em either.

This is the output, don't mind about the contents  :-[


Code: Text [Select]
  1. <p>[18.26.23] - Rotation was <font color = 'orange'><b>225</b></font> degrees, done by <b>127.0.0.1</b>, who says: '<b>HIGHWAY|||</p><p>|||-CHESS BOARD|||</p><p>|||</b>'


I've highlighted the tags with '|||'s, which cause problem and I assure you, that I've gone trought EVERY FILE RELATED trying to find where those tags pop-up.
I've tried using find in text-editor, I've tried to strip and trim them and no I don't know what to do anymore...

This is just my foolish theory but ... might it be possible, since 'HIGHWAY' and 'CHESSBOARD' are obtained from text-file,
that they somehow contain invisible tags or something after them? Like HIGHWAY<|/p><|p> ?


7
Oh my god, it works perfectly! THAAAANKS!
I was worried that nobody wouldn't make any sense of what I want to achieve  ;D

Now, to reverse that back ... Im going to seek for function which switches the key-table's keys with values like so:

OLD:

Code: PHP [Select]
  1. $cryptkey = array('0' => 286, '1' => 949, '2' => 695);

NEW:

Code: PHP [Select]
  1. $cryptkey = array('286' => 0, '949' => 1, '695' => 2);

Edit: array_flip seems to do the work.

8
Developer's Corner / [PHP] str_replace - is this even possible?
« on: March 28, 2011, 05:15 AM »
Hi again.
I'd like to make simple crypter by myself, this is what I've done so far:

Code: PHP [Select]
  1. //This is the key-table for crypter.
  2. $cryptkey = array('0' => 286, '1' => 949, '2' => 695, '3' => 348, '4' => 438, '5' => 977,
  3.         '6' => 320, '7' => 418, '8' => 970, '9' => 482, '[' => 466, ']' => 770, '.' => 569,
  4.         ' ' => 242, '-' => 166, 'A' => 583, 'B' => 575,  'C' => 247,  'D' => 564, 'E' => 192,
  5.          'F' => 513,  'G' => 653,  'H' => 605,  'I' => 450,  'J' => 404,  'K' => 831,  'L' => 315,  'M' => 953,
  6.           'N' => 439,  'O' => 266,  'P' => 231,  'Q' => 633,  'R' => 881,  'S' => 113,  'T' => 935,  'U' => 559,
  7.            'V' => 318,  'W' => 927,  'X' => 906,  'Y' => 463,  'Z' => 184, 'a' => 263,  'b' => 453,  'c' => 208,
  8.            'd' => 591,  'e' => 511, 'f' => 343,  'g' => 969,  'h' => 415,  'i' => 420,  'j' => 175,  'k' => 410,
  9.            'l' => 295,  'm' => 265, 'n' => 877,  'o' => 200,  'p' => 837,  'q' => 913,  'r' => 515,  's' => 262,
  10.            't' => 524,  'u' => 874, 'v' => 525,  'w' => 700,  'x' => 670,  'y' => 918,  'z' => 290, '<' => 331,
  11.            '>' => 533, "'" => 425, ',' => 101, ':' => 495, '$' => 114, '\\' => 268, '/' => 721, '=' => 454);
  12. //Don't mind about some fails in the table ... solving them later.
  13.  
  14. //This is the string we're going to crypt.
  15. $notcrypted1 = "[$curdate] - Rotation was <font color = '$color'><b>$rotation</b></font> degrees, done by <b>$ip</b>, who says: ''<b>$msg</b>''\r\n";
  16.  
  17. //Splitting the string here. (is this even needed?)
  18. $split1 = str_split($notcrypted1);
  19.  
  20. //And this is the problem area
  21. foreach ($split1 as $char) {
  22.         foreach ($cryptkey as $char2 => $key2) {
  23.                 $crypted1 = str_replace($char, $key2, $notcrypted1);
  24.                 }
  25.         }
  26.  
  27. //Im using this PHP.net's example
  28.  
  29. // Provides: Hll Wrld f PHP
  30. $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
  31. $onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

So basically, it is supposed to replace the characters in the $notcrypted1 with the key-table's corresponding int value.
But the problem is, that I'd like to know if there's any way to tell the program to switch the character it is going trought with the key-table's corresponding int value ... And like without doing 3000 if's.

Since it can replace the vowels with blank in the example - is it possible to switch the characters with the ints in my code?
My brains are jamming with this one ... I know it will not work like this and I even know why it isn't working - I just can't find a way to solve it ...


I wouldn't want to do it like so:

Code: PHP [Select]
  1. foreach ($split1 as $char) {
  2.         foreach ($cryptkey as $char2 => $key2) {
  3.                 if ($char == "A") {
  4.                         $crypted1 = str_replace($char, "A", $notcrypted1);
  5.                 }
  6.         }


9
Developer's Corner / Re: [PHP] Confused with functions
« on: February 06, 2011, 05:41 AM »
Yeah ... there's sometimes just too much questions I need answer for.
I'll go check the nearest library!

10
Developer's Corner / [PHP] Confused with functions
« on: February 05, 2011, 05:18 PM »
This has nothing to do with the thread I made few minutes ago.

Anyways ... I need help with these thing related to PHP-functions:

- How do I set what the function needs to work?

Like ...

Code: PHP [Select]
  1. function countNumbers() {
  2. echo ($x + $y);
  3. }

Now, how do I declare, that the function I made needs parameters $x and $y to count like so:
countNumber(1, 2);


Second question is, can function return multiple values, like with a loop?

Code: PHP [Select]
  1. function countNumbers() {
  2. $rtnval = $x + $y;
  3.  
  4. for ($i = 0; $i <= 5; $i++) {
  5. return $rtnval;
  6. }
  7. }


Third is, can I use function directly to output something like so:

Code: PHP [Select]
  1. echo countNumbers();

or

Code: PHP [Select]
  1. $numbers = countNumbers();
  2. echo Numbers;

Pages: prev1 [2] 3 4 5 6 7 ... 28next
Go to full version