/ Published in: PHP
                    
                                        
This PHP4 function will increment a given string by a given interval. This might be useful when a string has to be unique. An optional array with "forbidden" return values may be passed.
Usage:
                Usage:
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/**
* Increments a given string by given interval. An optional array with forbidden return values may be passed.
* @param string $string String to Increment
* @param int $increment Increment value, 1 by default
* @param array $forbidden Array with strings the function must not return.
* @return string Incremented string
* @uses String_Increment()
* @author Carsten Witt <[email protected]>
* @version 20060706-2230
*/
$regex = "(_?)([0-9]+)$";
$neu = ((int) $z) + $increment;
$string = ereg_replace((($z=='') ? "$" : $regs[0]."$"), ((string) $regs[1]).((string) $neu), $string);
return $string;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                