|
|
|
| Title : |
Exploder class . Explodes a string into segments given any
amount of delimiters. Can also esc characters.Useful for
parsing query input from a form. |
| Categories : |
PHP Classes, HTTP |
 Ed Williams |
| Date : |
May 04th 1999 |
| Grade : |
2 of 5 (graded 3 times) |
| Viewed : |
6408 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Ed Williams |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?
/******************************************************************
class Exploder
*******************************************************************
Purpose : split a string up into segments given delimiter(s)
Usage : pizza = "slice1:slice2|'slice3:|slice4'";
expl = new Exploder(array(":","|"), pizza, "'");
slices = expl->GetSegments();
NOTE : segment three will be slice3:|slice4 because inbetween
esc chars
*******************************************************************/
class Exploder {
var $m_segments;
function Exploder($tokens, $string, $esc="") {
$string = stripslashes($string);
$segstart = false;
$escstart = false;
// loop through characters in string
for ($i=0; $i < strlen($string); $i++) {
$char = $string[$i];
// check if token char
for ($t=0; ($t < count($tokens)); $t++)
if ($char == $tokens[$t] || $char == $esc)
break;
// if not a token
if ($t == count($tokens) || $escstart && $char != $esc)
{
$segstart = true;
$segment .= $char;
} else {
if ($segstart) {
$this->m_segments[] = $segment;
$segment = "";
}
$segstart = false;
}
// check if esc has begun or ended
if ($char == $esc)
$escstart = !$escstart;
}
if ($segstart)
$this->m_segments[] = $segment;
}
function GetSegments() {
return $this->m_segments;
}
function GetNumber() {
return count($this->m_segments);
}
};
?> |
|
| Request Method Class - seful for situations like form processing or API development. Requires PHP5 for the magic __call() method.
Categories : PHP, PHP Classes, HTTP, Headers | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | Gonx Proxy - This class is meant to act as an HTTP proxy to serve pages of a remote server as if they were local pages.
Categories : PHP, PHP Classes, HTTP | | | Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem | | | Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags. Categories : PHP, PHP Classes, Algorithms, Security | | | PHP Transfer data from text file to Mysql Table Categories : PHP, PHP Classes, Filesystem, Databases, MySQL | | | A Custom Error Handling And Debugging Class Categories : PHP, PHP Classes, Debugging, Errors and Logging | | | Sitmap Generator PHP class Categories : PHP, PHP Classes, Search Engines, Site Planning | | | Difference between POST and GET methods of Submitting Forms Categories : HTML, HTTP | | | Use this class to connect your database transparently... Categories : PHP Classes, Databases, PHP | | | Sort the results from a SELECT query (any number of columns) into an array automatically. Categories : PHP, PHP Classes, Arrays, Databases, MySQL | | | Class TStringList include some metods from class TStringList
implemented in INPRISE/BORLAND-DELPHI Categories : PHP Classes, PHP, Strings | | | SubmitForce URL power submitter (searchengine submission class) Categories : PHP, Search Engines, URLs, PHP Classes | | | usercounter class Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables | | | Link Manager for Link Exchangers Categories : PHP, PHP Classes, Databases, MySQL, CURL | |
| |
| | | | | Screw Driver wrote :300
Very nice class. Works Perfectly. Thanks!!!
| |
|
|