Solved

php remove characters afer comma

Posted on 2004-09-01
2
439 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
Comment Utility
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
Comment Utility
great
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…

772 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

8 Experts available now in Live!

Get 1:1 Help Now