Login   Register  
PHP Classes
elePHPant
Icontem

File: string.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrei Caminschi  >  MySQLQueryGenerator  >  string.php  >  Download  
File: string.php
Role: Auxiliary script
Content type: text/plain
Description: Basic strings operations
Class: MySQLQueryGenerator
Compose common MySQL queries from parameters
Author: By
Last change:
Date: 2009-10-02 03:58
Size: 1,156 bytes
 

Contents

Class file image Download
<?php

function low($str){return strtolower($str);}
function 
up($str){return strtoupper($str); }
function 
rep($search,$replace,$subject){return str_replace($search,$replace,$subject);}
function 
len($str){ return strlen($str);}
function 
stripTrailingChars($str,$count){return substr($str,0,len($str)-$count);}

function 
camelCaseGetParts($str$count=0)
{
    
$parts            = array()        ;
    
$partIndex    =    1                    ;
    
$len                =    len($str)    ;
    
    for(
$i=0;$i<$len;$i++)
    {
        
$char    $str[$i];
        if (
$char===up($char))$partIndex++;
        if(
$partIndex-== $count-&& $count != 0)
        {
            
$parts[$partIndex-1] = substr($str,$i,len($str));
            return 
$parts;
        }
        
$parts[$partIndex-1] .= $char;
    }
    return 
$parts;
    
}

function 
seriaizeAssocArray($array$keyWrap,$betweenOp,$valueWrap,$sep)
{
    
$str    "";
    foreach ( 
$array as $k=>$v)
        
$str.= "{$keyWrap}{$k}{$keyWrap}{$betweenOp}{$valueWrap}{$v}{$valueWrap}{$sep}";
    return 
stripTrailingChars($str,1);
}

function 
seriaizeArray($array$valueWrap,$sep)
{
    
$str    "";
    foreach ( 
$array as $k=>$v)
        
$str.= "{$valueWrap}{$v}{$valueWrap}{$sep}";
    return 
stripTrailingChars($str,1);
}


?>