note 39261 added to function.split
| From: | biohazard at online dot ge | Date: | Thu, 22 Jan 2004 12:33:11 +0000 |
| Subject: | note 39261 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64011@lists.php.net to get a copy of this message | ||
for the first times it was difficult to learn the use of RegXP and i wrote some these coool and easy
functions for strings...
eg. use AFTER to determinate what is after '=' in 'max_urls=14' the result is
'14'
and so on, on other ones....
OR
use BETWEEN to determinate what is between '(' and ')' in 'sin(90)'
result is '90'
function after ($this, $inthat)
{
if (!is_bool(strpos($inthat, $this)))
return substr($inthat, strpos($inthat,$this)+strlen($this));
};
function after_last ($this, $inthat)
{
if (!is_bool(strrevpos($inthat, $this)))
return substr($inthat, strrevpos($inthat, $this)+strlen($this));
};
function before ($this, $inthat)
{
return substr($inthat, 0, strpos($inthat, $this));
};
function before_last ($this, $inthat)
{
return substr($inthat, 0, strrevpos($inthat, $this));
};
function between ($this, $that, $inthat)
{
return before($that, after($this, $inthat));
};
function between_last ($this, $that, $inthat)
{
return after_last($this, before_last($that, $inthat));
};
//this function is required:
function strrevpos($instr, $needle)
{
$rev_pos = strpos (strrev($instr), strrev($needle));
if ($rev_pos===false) return false;
else return strlen($instr) - $rev_pos - strlen($needle);
};
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39261
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39261&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39261&report=yes
Search -- http://master.php.net/manage/user-notes.php