Solved

php remove characters afer comma

Posted on 2004-09-01
2
441 Views
Last Modified: 2008-01-09
i have a string...

$string='jpratt, iii';

I want php to remove all characters after the comma...including removing the comma. How do i do this?
0
Comment
Question by:cimmer
2 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 266 total points
ID: 11953008
All sorts of ways.  Here are two.

$string = substr($string, 0, strpos($string, ","));

OR

$myArray = explode(",", $string);
$string = $myArray[0];

http://www.php.net/manual/tw/ref.strings.php
0
 

Author Comment

by:cimmer
ID: 11953178
great
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 look for a specific file type in a local or remote server directory using PHP.

864 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

24 Experts available now in Live!

Get 1:1 Help Now