|
Home - Computerkurs Demos Editpointstatic Folderwatcher Gipsydrive Licenses Shrinkseries V4 More... All Asm Bas C C++ C# Couch CSS HTML Java JS Lisp OPAL PHP Perl PS Py SQL Win |
|
Downtown Programmer's Corner - Demos
PHP ...
.
.
Problem: We have two strings and want know, up to which position they are identical.
|
|
A cool solution is found on Stackoverflow in tread "Find first character that is different between two strings", in the posting by ircmaxell on 2011-September-19. He says: "... when you xor two strings, the characters that are the same will become null bytes (chr(0)) ...". . BTW ircmaxell writes nice PHP articles in his blog blog.ircmaxell.com . |
In esp/esp.index.php in function # 20110923.0721 it looks like this:
$s1 = $_SERVER['HTTP_REFERER']; // "http://localhost/eps/testpage.html"; $s2 = $_SERVER['SCRIPT_URI'] // "http://localhost/eps/eps/index.php"; $sXor = $s1 ^ $s2; $iPos = strspn($sXor, chr(0)); $sTail1 = substr($s1, $iPos); // = "testpage.html" $sTail2 = substr($s2, $iPos); // = "eps/index.php"
.
.
|
|
Stackoverflow thread How to send a GET request from PHP? is enumerating some methods to do the job . | Thread |
.
Jörg Krause: Kochbuch PHP5, (c) 2005 Carl Hanser Verlag München Wien, ISBN 3-446-22736-9, 508 pages, www.hanser.de/computer (Demos from this book are in project Wakati Gallery :)
.
.
.
Imprint : www.trilo.de/imprint.html