/    Sign up×
Community /Pin to ProfileBookmark

How to Hide Part of String?

How would I hide part of a string (up to and including a slash)? So if my string is “firstpart/secondpart” — I need it to only output “secondpart”.

Thank you for your help.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyJul 05.2013 — You're not "hiding" anything. You're extracting a substring. Start with http://www.php.net/manual/en/function.substr.php
Copy linkTweet thisAlerts:
@msmith29063authorJul 05.2013 — Yes. That's correct. But the string length/content is going to vary. Not sure substr() would handle that. Thoughts?
Copy linkTweet thisAlerts:
@rtretheweyJul 05.2013 — If you have a specific marker of some kind, you can use strpos() to locate it in the original string and then use the result in substr(). See http://www.php.net/manual/en/function.strpos.php
Copy linkTweet thisAlerts:
@msmith29063authorJul 05.2013 — I stil don't know how this would look with strpos(). Can you offer an example?
Copy linkTweet thisAlerts:
@rtretheweyJul 06.2013 — Extracting substrings is a common task, and like many programming issues, there are several different ways of doing it. The best choice depends on exactly what you're trying to do. It would also be helpful to have an idea of your programming skills so that I'm not just spoon-feeding you code that might solve your example problem, but would be of little use in solving your actual problem. Could you post some of your existing code so I can get an idea of what you're trying to do and where you are at the moment.
Copy linkTweet thisAlerts:
@msmith29063authorJul 06.2013 — Thank you for the explanation. I've got it worked out. Ended up using strtok().
×

Success!

Help @msmith29063 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...