|
|
|
| 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 : |
1 of 5 (graded 2 times) |
| Viewed : |
5194 |
| 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);
}
};
?> |
|
| 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 | | | 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 | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Excel class in PHP Categories : PHP, PHP Classes, Excel | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | The following snippet gives complete info about all submitted
HTTP_POST_VARS and HTTP_GET_VARS Categories : Variables, HTTP, PHP | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Simple Template Class/Example Categories : PHP, Templates, PHP Classes | | | MS Word Mail Merge Automation (COM) Categories : PHP, PHP Classes, COM | | | Very minimal templating engine Categories : PHP, PHP Classes, Templates | | | XPath for PHP without the DOM XML extension Categories : DOM XML, XML, XSLT, PHP Classes, PHP | |
| | | | Screw Driver wrote :300
Very nice class. Works Perfectly. Thanks!!!
| |
|
|
|