WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : STR - a Perl-like string manipulator class - The str class provides 4 perl-like methods for manipulating strings and other scalar variables.
Categories : PHP, PHP Classes, Perl, Strings Click here to Update Your Picture
Zak Greant
Date : Feb 14th 2001
Grade : 1 of 5 (graded 1 times)
Viewed : 8599
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Zak Greant
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
/*
+----------------------------------------------------------------------+
| Copyright (c) 2000 J.A.Greant |
| (See end of file for usage notes and licensing information.) |
+----------------------------------------------------------------------+
*/

class str
{
function pop (&$string)
{
if ( 0 == strlen ($string) || is_array ($string))
return FALSE;

$pop = substr ($string, -1);
$string = substr ($string, 0, -1);
return $pop;
}

function push (&$var)
{
if (is_array ($var) || is_object ($var) || is_resource ($var))
return FALSE;

$args = func_get_args ();
$var = implode ('', $args);
return strlen ($var);
}

function shift (&$string)
{
if ( 0 == strlen ($string) || is_array ($string))
return FALSE;

$unshift = substr ($string, 0, 1);
$string = substr ($string, 1);
return $unshift;
}

function unshift (&$var)
{
if (is_array ($var) || is_object ($var) || is_resource ($var))
return FALSE;

$args = array_reverse (func_get_args ());
$var = implode ('', $args);
return strlen ($var);
}
}
/*
+----------------------------------------------------------------------+
| FILE NAME: str.php |
+----------------------------------------------------------------------+
| Author: J.A.Greant |
| Email : zak@nucleus.com |
| Date : 2000/11/23 |
+----------------------------------------------------------------------+
| The str class provides 4 perl-like methods for manipulating strings |
| and other scalar variables. |
| |
|--> WARNING: The following methods operate directly on the values <--|
|--> passed to them. pop and shift shorten the value passed, while <--|
|--> push and unshift make the first variable passed to the method <--|
|--> contain all of the values passed to the method. <--|
| |
| str::pop() method |
| ----------------- |
| Strip the rightmost character from a scalar variable and return the |
| character. |
| NOTE: pop() must be used on a variable and not a literal value. |
| |
| USAGE EXAMPLE: |
| $string = "Humpty Dumpty sat on a wall."; |
| $chr = str::pop ($string); |
| print $chr; // Contains "." |
| print $string; // Contains "Humpty Dumpty sat on a wall" |
| |
| str::push() method |
| ------------------ |
| Join one or more scalar values onto the right end of a scalar |
| variable. The values are concatenated from left to right, in the |
| order that they were specified. |
| NOTE: The first argument for push() must be a variable and not a |
| literal value. All other arguments may be literal values. |
| |
| USAGE EXAMPLE: |
| $string = "Humpty Dumpty sat on a wall.\n"; |
| $string_2 = "Humpty Dumpty had a great fall.\n"; |
| $length = str::push ($string, $string_2); |
| print $length; // Contains 61 |
| print $string; // Contains $string . $string_2 |
| |
| str::shift() method |
| ------------------- |
| Strip the leftmost character from a scalar variable and return the |
| character. |
| NOTE: shift() must be used on a variable and not a literal value. |
| |
| USAGE EXAMPLE: |
| $string = "Humpty Dumpty sat on a wall."; |
| $chr = str::shift ($string); |
| print $chr; // Contains "H" |
| print $string; // Contains "umpty Dumpty sat on a wall." |
| |
| str::unshift() method |
| ------------------ |
| Join one or more scalar values onto the left end of a scalar |
| variable. The values are concatenated from right to left, in the |
| order that they were specified. |
| NOTE: The first argument for unshift() must be a variable and not a |
| literal value. All other arguments may be literal values. |
| |
| USAGE EXAMPLE: |
| $string = 'fe'; |
| $length = str::unshift ($string, 'fi', 'fo', 'foo'); |
| print $length; // Contains 9 |
| print $string; // Contains "foofofife" |
+----------------------------------------------------------------------+

+----------------------------------------------------------------------+
| CVS LOG INFO |
+----------------------------------------------------------------------+
$Log: str.pkg,v $
Revision 1.3 2001/01/02 03:56:14 zak
Added tests to handle empty strings for pop and shift.

$Log: str.pkg,v $
Revision 1.2 2000/11/24 02:08:04 zak
Simplified code for push and unshift.
Removed extraneous comments.

Revision 1.1.1.1 2000/11/24 01:49:50 zak
Initial import of php code
repository


+----------------------------------------------------------------------+
| Copyright (c) 2000 J.A.Greant (zak@nucleus.com) |
| All rights reserved. |
+----------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, is permitted provided that the following conditions |
| are met: |
+----------------------------------------------------------------------+
| Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| |
| Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| |
| Neither the name of the author nor the names of any contributors to |
| this software may be used to endorse or promote products derived |
| from this software without specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| POSSIBILITY OF SUCH DAMAGE. |
+----------------------------------------------------------------------+
*/
?>



Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Class TStringList include some metods from class TStringList implemented in INPRISE/BORLAND-DELPHI
Categories : PHP Classes, PHP, Strings
PHP5 URL Object
Categories : PHP, PHP Classes, URLs, Strings
PHP Object Example of the Perl DBI with MySQL
Categories : PHP, PHP Classes, MySQL, Databases, Perl
Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
Working with files - putting file contents to a string / var
Categories : PHP, Filesystem, Variables, Strings
How to find the name of the current file?
Categories : PHP, Filesystem, Strings
XTemplate, a template class for PHP
Categories : PHP Classes, HTML and PHP, PHP
Sample usage of IPv6 and IPv4 with PHP
Categories : PHP, PHP Classes, Network
SPL and ITERATOR : examples
Categories : PHP, Object Oriented, PHP Classes, Sessions
credit card security code
Categories : PHP, Credit Cards, PHP Classes, Credit Cards
TableMaint: class to help in the updating of data stored in database tables
Categories : PHP, PHP Classes, Databases
Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form
Categories : HTML, PHP, Strings
XML To Array
Categories : PHP, PHP Classes, XML, Arrays
imageMarker v 3.00 with new advanced features
Categories : PHP, PHP Classes, Graphics, GD image library