Solved

getting data after | mark

Posted on 2009-04-01
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

762 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