2016-07-31 05:18:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Common String Functions
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @category Common
|
|
|
|
* @package Functions\Strings
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
* @copyright 2016 Jim Wigginton
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @link http://phpseclib.sourceforge.net
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace phpseclib\Common\Functions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Common String Functions
|
|
|
|
*
|
|
|
|
* @package Functions\Strings
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
*/
|
2016-12-01 04:43:03 +01:00
|
|
|
abstract class Strings
|
2016-07-31 05:18:06 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* String Shift
|
|
|
|
*
|
|
|
|
* Inspired by array_shift
|
|
|
|
*
|
|
|
|
* @param string $string
|
|
|
|
* @param int $index
|
2016-07-31 15:54:57 +02:00
|
|
|
* @access public
|
2016-07-31 05:18:06 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
2016-12-03 21:39:11 +01:00
|
|
|
public static function shift(&$string, $index = 1)
|
2016-07-31 05:18:06 +02:00
|
|
|
{
|
|
|
|
$substr = substr($string, 0, $index);
|
|
|
|
$string = substr($string, $index);
|
|
|
|
return $substr;
|
|
|
|
}
|
2016-12-03 21:39:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* String Pop
|
|
|
|
*
|
|
|
|
* Inspired by array_pop
|
|
|
|
*
|
|
|
|
* @param string $string
|
|
|
|
* @param int $index
|
|
|
|
* @access public
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function pop(&$string, $index = 1)
|
|
|
|
{
|
|
|
|
$substr = substr($string, -$index);
|
|
|
|
$string = substr($string, 0, -$index);
|
|
|
|
return $substr;
|
|
|
|
}
|
2016-07-31 05:18:06 +02:00
|
|
|
}
|