Solved

getting data after | mark

Posted on 2009-04-01
2
205 Views
Last Modified: 2013-12-12
i have a drop down menu which holds 3 different values

withoutMinutes|400m                  
withoutHours|10k Road
withHours|Marathon

how could  strip it so i can just add anything after | into my db?

so into my db would be

400m                  
10k Road
Marathon
0
Comment
Question by:runnerjp
2 Comments
 
LVL 4

Expert Comment

by:phpmonkey
ID: 24044290
in this case where there is only 1 pipe symbol in it i would explode it.
list($part1,$part2) = explode("|",'withoutMinutes|400m');

echo $part1;//withoutMinutes

echo $part2;//400m

Open in new window

0
 
LVL 13

Accepted Solution

by:
marchent earned 500 total points
ID: 24044319
using preg_repalce() remove anything before | with empty
$str = 'withoutMinutes|400m';

$str = preg_replace('/.*\|/', '', $str);

print "$str\n";

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now