Advertisement

07.19.2008 at 06:08PM PDT, ID: 23579603
[x]
Attachment Details

If a string has one period how can I return the information before the period, if the string has 2 periods how can I return the information between the periods.

Asked by jonathanbyers in PHP Scripting Language, PHP and Databases

Tags: ,

I have a string that could have one period or 2 periods in it.  See examples below to see what I was to return.  The list of information is pulled from a mySQL database, but I'm not sure if that is relevant.

If the string has one period:  BEGINNING.MIDDLE - Would return BEGINNING
If the string has two periods: BEGINNING.MIDDLE.END - Would return MIDDLE

Also if once the values are pulled if there are duplicates than only one will be listed. The select statement selects distinct, but I would need to list distinct after the string has pulled out the values.

Below is the code that lists the values.Start Free Trial
1:
2:
3:
$result = mysql_query("SELECT distinct USERDOMAIN FROM results ORDER BY USERDOMAIN ASC");
while($r=mysql_fetch_array($result)){	
  $userdomain=$r["USERDOMAIN"];
[+][-]07.19.2008 at 06:36PM PDT, ID: 22044179

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, PHP and Databases
Tags: PHP, All
Sign Up Now!
Solution Provided By: Tchuki
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.19.2008 at 06:44PM PDT, ID: 22044187

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 09:38PM PDT, ID: 22044591

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 11:43PM PDT, ID: 22044777

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 12:05AM PDT, ID: 22044829

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 12:10AM PDT, ID: 22044837

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.20.2008 at 12:17AM PDT, ID: 22044848

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628