Jump to content

Recommended Posts

All-

 

I have a PHP string that consists of the following.

 

 

$Directory = "DIR/*FILENAME/FILEA/FILEB"

 

Now I am currently using

$Directory = strrchr($Directory, '*');

 

To shorten it to

$Directory = "*FILENAME/FILEA/FILEB"

 

That part is working like a champ.  Where I am running into trouble is I want to make the string look like the following.

 

$Directory = "*FILENAME

 

Now I thought about going X amount of characters over from the * but what happens then 'FILENAME' changes in size.  also tried using the strrchr function but that seems to work from left to right... I need something that works from right to left.

 

 

Any Ideas????

Link to comment
https://forums.phpfreaks.com/topic/181456-find-an-occurance-in-a-php-string/
Share on other sites

Thanks for taking a look.  I tried that exact code and it doesen't print anything to the screen.  If I break it appart...

$Directory = "*FILENAME/FILEA/FILEB";

$Directory = substr($Directory, 0);

echo $Directory = strpos('/', $Directory);

 

Still Doesn't Display anything.  If I take the strpos part out, then it semi works but doesent do as needed.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.