473,236 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

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 22222
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rdraider | last post by:
Is there a function that will extract part of a string when the data you want does not occur in a specific position? Field "REF" is varchar(80) and contains an email subject line and the email...
5
by: nboutelier | last post by:
Scenario: you enter "foo bar" into a text field... Is it possible through javascript to select/highlight just "foo"? formObject.select() selects all. I need to select only part of the string....
5
by: ad | last post by:
I have a string like string myString="dog,cat,dog,tiger" I want to delete the duplication part, and make myString to "dog,cat,tiger" How can I do that?
4
by: Keith Kowalski | last post by:
I am passing in a string of varied length Example1: mil2345_23.lst Example2: mil23456_1.lst Example3: mil5567_1234.lst What I need is to parse out all text after the _ (underscore) and before...
5
by: Piotr | last post by:
Hi, Im trying to write a query which takes part of the string for example: peter_Poland michael_Germany I wish to get output: peter michael
2
by: Alpha | last post by:
Hi, I'm able to make connection to a server using socket connection. However, when I send a command string the server just ignores it. All command string needs to start with "0xF9" at Byte 0. ...
3
by: MMiGG | last post by:
Hi Our project need parse JAVA serialized object string in C, has any library? Thanx
8
by: Mike9900 | last post by:
I need to get 00021 in "00sddsd00021dsd" and then increment it to become "00sddsd00022dsd". Is there a way? -- Mike
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.