|
-
Mar 5th, 2005, 06:27 AM
#1
Thread Starter
Addicted Member
a function from VB to PHP[solved]
hi, can somebody convert the VB code below to php
VB Code:
Private Function Between(Begining As String, Ending As String, TextToLookIn As String) As String
Dim Be, En, TTLI As String
Be = Begining
En = Ending
TTLI = TextToLookIn
TTLI = Right(TTLI, Len(TTLI) - (InStr(1, TTLI, Be) + Len(Be) - 1))
Between = Left(TTLI, InStr(1, TTLI, En) - 1)
End Function
Last edited by kill_bill_gates; Mar 5th, 2005 at 09:28 AM.
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
Mar 5th, 2005, 06:30 AM
#2
Re: a function from VB to PHP
-
Mar 5th, 2005, 06:32 AM
#3
Thread Starter
Addicted Member
Re: a function from VB to PHP
it returns the string value between "Beginning" and "Ending" variables, in the given text.
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
Mar 5th, 2005, 06:40 AM
#4
Re: a function from VB to PHP
So if I have a string:
PHP Code:
$str = 'This is a test string with some random words';
echo(Between('test', 'random', $str));
The ouput would be:
"string with some" ?
-
Mar 5th, 2005, 06:55 AM
#5
Thread Starter
Addicted Member
Re: a function from VB to PHP
yes
can you do it in PHP?
Last edited by kill_bill_gates; Mar 5th, 2005 at 07:02 AM.
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
Mar 5th, 2005, 07:32 AM
#6
Re: a function from VB to PHP
Done:
PHP Code:
function between($start, $end, $string)
{
$pos1 = strpos($string, $start) + strlen($start);
$pos2 = strpos($string, $end) - 1;
return substr($string, $pos1, $pos2 - $pos1 + 1);
}
I'll let you decide its behviour if one or both the search strings are not found.
-
Mar 5th, 2005, 07:44 AM
#7
Re: a function from VB to PHP
Bill Gates killer, that is in PHP... just add the
<?
?>
tags to it...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|