Solved

getting data after | mark

Posted on 2009-04-01
2
208 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 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