469,281 Members | 2,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

Parse part of string (mid string function ?)

Can someone tell me how to parse part of a string? I can use the following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out
parts of other strings. I know how to use Mid(), Left(), and Right() in VB,
but no clue for PHP.

Thanks in advance for the assistance.

Jul 17 '05 #1
8 21987
mimages wrote:
Can someone tell me how to parse part of a string? I can use the following: [...] I know how to use Mid(), Left(), and Right() in VB,
but no clue for PHP.


check the substr() function @ http://www.php.net/substr.

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #2
I noticed that Message-ID:
<9V********************@twister.tampabay.rr.com> from mimages contained
the following:
<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash.


<?php
$text = str_replace("/","","$_SERVER[PHP_SELF]");
echo $text;
?>

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
On Thu, 25 Sep 2003 14:36:53 +0100, Geoff Berrow wrote:
I noticed that Message-ID:
<9V********************@twister.tampabay.rr.com> from mimages contained
the following:
<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url); echo
$text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash.


<?php
$text = str_replace("/","","$_SERVER[PHP_SELF]");
echo $text;
?>

$text = array_pop(split('/', $_SERVER['PHP_SELF']));
echo $text;
Just as another example.. although not tested for efficiency =)

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 17 '05 #4

"mimages" <mi*****@NOSPAMspvision.com> wrote in message
news:9V********************@twister.tampabay.rr.co m...
Can someone tell me how to parse part of a string? I can use the following:
<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out
parts of other strings. I know how to use Mid(), Left(), and Right() in VB, but no clue for PHP.

Thanks in advance for the assistance.


<?php

$text = basename($_SERVER['PHP_SELF']);
echo $text;

?>

Jul 17 '05 #5
An noise sounding like Ian.H said:
On Thu, 25 Sep 2003 14:36:53 +0100, Geoff Berrow wrote:
I noticed that Message-ID:
<9V********************@twister.tampabay.rr.com> from mimages contained
the following:
<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url); echo
$text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash.


<?php
$text = str_replace("/","","$_SERVER[PHP_SELF]");
echo $text;
?>

$text = array_pop(split('/', $_SERVER['PHP_SELF']));
echo $text;
Just as another example.. although not tested for efficiency =)

You didn't test your code works so as to answer more questions, thus improving
your efficiency

or
You didn't test the speed your code ran an vs the speed of the other to see
which was more efficient

??????

Dave.
--

I'm a dead man, and buggered to boot!

Jul 17 '05 #6
Wow, basename, I don't think I'd have thought of this one. I'll try it.
Thanks!

"medi" <me**@banjaluka.com> wrote in message
news:bk**********@news.teol.net...

"mimages" <mi*****@NOSPAMspvision.com> wrote in message
news:9V********************@twister.tampabay.rr.co m...
Can someone tell me how to parse part of a string? I can use the

following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out parts of other strings. I know how to use Mid(), Left(), and Right() in

VB,
but no clue for PHP.

Thanks in advance for the assistance.


<?php

$text = basename($_SERVER['PHP_SELF']);
echo $text;

?>

Jul 17 '05 #7
Thanks for all the graet responses. Time to get to work trying them.
"David Gillen" <Be****@RedBrick.DCU.IE> wrote in message
news:sl*******************@carbon.redbrick.dcu.ie. ..
An noise sounding like Ian.H said:
On Thu, 25 Sep 2003 14:36:53 +0100, Geoff Berrow wrote:
I noticed that Message-ID:
<9V********************@twister.tampabay.rr.com> from mimages contained
the following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url); echo
$text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash.

<?php
$text = str_replace("/","","$_SERVER[PHP_SELF]");
echo $text;
?>

$text = array_pop(split('/', $_SERVER['PHP_SELF']));
echo $text;
Just as another example.. although not tested for efficiency =)

You didn't test your code works so as to answer more questions, thus

improving your efficiency

or
You didn't test the speed your code ran an vs the speed of the other to see which was more efficient

??????

Dave.
--

I'm a dead man, and buggered to boot!

Jul 17 '05 #8
Yup, sure enough, this is what I was looking for.

Thanks!
"mimages" <mi*****@NOSPAMspvision.com> wrote in message
news:Bf********************@twister.tampabay.rr.co m...
Wow, basename, I don't think I'd have thought of this one. I'll try it.
Thanks!

"medi" <me**@banjaluka.com> wrote in message
news:bk**********@news.teol.net...

"mimages" <mi*****@NOSPAMspvision.com> wrote in message
news:9V********************@twister.tampabay.rr.co m...
Can someone tell me how to parse part of a string? I can use the

following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out parts of other strings. I know how to use Mid(), Left(), and Right()
in VB,
but no clue for PHP.

Thanks in advance for the assistance.


<?php

$text = basename($_SERVER['PHP_SELF']);
echo $text;

?>


Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by rdraider | last post: by
4 posts views Thread by Keith Kowalski | last post: by
8 posts views Thread by Mike9900 | last post: by
22 posts views Thread by Terry Olsen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.