Source for file Strings.class.php
Documentation is available at Strings.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
* Loading the class to manipulate arrays.
include_once( CLASSPATH. "core/Arrays.class.php" );
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (c) 2003 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* Functions like strpos( string haystack, string needle [, int offset] ),
* but you can use a regular expression as needle.
* BEWARE: lookahead, lookbehind and all chars itentified by their position
* will NOT function, because of the intern relay to the function
* @param string $haystack
function pregpos( $haystack, $needle, $offset = 0 )
$haystack = substr( $haystack, $offset );
$tmp_match_arr = array();
if ( preg_match( $needle, $haystack, $tmp_match_arr ) )
$pos = strpos( $haystack, $tmp_match_arr[0] );
* Make a string uppercase atleast for ISO-8859-1 (Latin 1) full with all
* @see http://www.php.net/manual/en/function.strtoupper.php#78498
$pattern = '/&([a-z])(uml|acute|circ';
$pattern .= '|tilde|ring|elig|grave|slash|horn|cedil|th);/e';
$replace = "'&'.strtoupper('\\1').'\\2'.';'";
// convert from entities back to characters
foreach ( $htmltable as $key => $value )
* Replaces substrings in string by the matching keys of an array to the
* Puts out "D. Pluecken".
* @param array $array The array that holds the replace list.
* @param string $string The string which should be modified.
foreach ( $array as $key => $value )
* Escapes all line breaks in a string with \.
* @param string $text The string which should be modified.
* Removes all line breaks in a string.
* @param string $text The string which should be modified.
* Removes all white spaces including tabs and line breaks in a string.
* @param string $text The string which should be modified.
* Reduces in series lying spaces to only one space. Also all spaces at the
* beginning of a line will be removed.
* @param string $text The string which should be modified.
* Adds $char to string until string has the length of $digits.
* Strings::leadingChar( "0", "5", 4 );
* @param char $char The char that should add to $string.
* @param string $string The string that schould be extended.
* @param integer $digits The count of digits $string schould get.
$tmp = $digits - strlen( $string );
* Returns whether the given string begins with substring $what.
* @param string $string The string which should be checked if it starts
* @param string $what The substring which will be compared with the
* Returns whether the given string ends with substring $what.
* @param string $string The string which should be checked if it ends
* @param string $what The substring which will be compared with the
* Splits a string by $separator. Every extracted piece will be concatenate
* with $beforeRPL at the beginning and $behindRPL at the ending of its own.
* At least all pieces will put together to a new string. Optionally the
* pieces will be separate by a new separator which is given with the fifth
* @param string $seperator
* @param string $beforeRPL
* @param string $behindRPL
* @param string $seperatorRPL
$tmp = explode( $separator, $string );
. implode( $behindRPL. $separatorRPL. $beforeRPL, $tmp )
* Returns the first Word from a text.
* @param string $string The string that schould be extended.
$string = trim( $string );
return preg_replace( "!^([^ \t\n\r]+).*$!is", "$1", $string );
* Returns a coincidence created password with given digits.
{ die( "\"". $digits. "\" is not an integer!" ); }
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '.', ',', ';', ':', '#',
'+', '-', '!', '\"', '$', '\'', '*', '%', '/', '<', '>',
'|', '(', ')', '[', ']', '{', '}', '?', '=', '&', '\\'
for( $i = 0; $i < $digits; $i++ )
* Returns a coincidence created word with given digits.
{ die( "\"". $digits. "\" is not an integer!" ); }
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
for( $i = 0; $i < $digits; $i++ )
* Interprets arguments given by an URL.
if( !preg_match( "!GLOBALS|GET|POST|REQUEST|ALL!i", $kind ) )
"Following values are possible to set the output-kind "
. "of the arguments:<br><br>"
. "GLOBALS (to store the values in the \"\x24GLOBALS\"-array)<br>"
. "GET (to store the values in the \"\x24_GET\"-array)<br>"
. "POST (to store the values in the \"\x24_POST\"-array)<br>"
. "REQUEST (to store the values in the \"\x24_REQUEST\"-array)<br><br>"
. "ALL (to store the values in every possible kind of array - "
. "this overrules the other settings)<br><br>"
. "All kinds can be used in combination, but the \"ALL\"-kind "
. "overrules the other settings."
preg_match_all( "!", $string, $token, PREG_PATTERN_ORDER );
for( $i = 0; $i < count( $token[1] ); $i++ )
# extract arguments and values
$token[1][$i], $param_val,
$_REQUEST[$param_val[1][0]] = $param_val[2][0];
$_POST[$param_val[1][0]] = $param_val[2][0];
$_GET[$param_val[1][0]] = $param_val[2][0];
$GLOBALS[$param_val[1][0]] = $param_val[2][0];
} // End of class Strings
|