Results 1 to 6 of 6
-
09-20-2014, 06:47 PM #1Web Host Reviewer
- Join Date
- Feb 2006
- Location
- Kepler 62f
- Posts
- 16,703
Remove everything after punctuation in php?
Let's say I have:
John likes bananas, apples and oranges
What I want is:
John likes bananas
Everything after the , is removed.
I'm currently starting with this one snippet of code in WordPress:
Code:<?php echo get_the_term_list($post->ID, TAXONOMY_NAME, ' ', ', ', ''); ?>
How can I alter this one piece of code to do that?|| Need a good host?
|| See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
||
-
09-20-2014, 07:00 PM #2Web Host Reviewer
- Join Date
- Feb 2006
- Location
- Kepler 62f
- Posts
- 16,703
This may be what I need, but having a hard time isolating the exact syntax needed:
http://stackoverflow.com/questions/1...er-a-character|| Need a good host?
|| See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
||
-
09-20-2014, 07:47 PM #3Junior Guru
- Join Date
- Oct 2004
- Location
- Celebration, Florida
- Posts
- 209
$phrase = "John likes apples, oranges and bananas.";
$separate = explode(",",$phrase);
echo $separate[0];▒ Richard C. Hay - Celebration, Florida
▒ Web Application Development, Graphic Design & Organization Management Services
-
09-20-2014, 08:22 PM #4Web Host Reviewer
- Join Date
- Feb 2006
- Location
- Kepler 62f
- Posts
- 16,703
But how do I integrate it into the above snippet of code?
That's where I'm stuck.|| Need a good host?
|| See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
||
-
09-20-2014, 09:37 PM #5Geek Of All Trades
- Join Date
- Jul 2009
- Location
- NC
- Posts
- 938
Code:<?php $phrase = get_the_term_list($post->ID, TAXONOMY_NAME, ' ', ', ', ''); $separate = explode(",",$phrase); echo $separate[0]; ?>
☆☆☆ Cool Domain Names - DomainSale.link☆☆☆
-
09-20-2014, 09:50 PM #6Web Host Reviewer
- Join Date
- Feb 2006
- Location
- Kepler 62f
- Posts
- 16,703
No, something odd is still going on there. It crashes the page.
I'm just to to give up on this one. I can make another custom field instead, and use it for displaying the shorter text.
Thanks, though.
At least I know it's not just me. Nobody can seem to get this working.|| Need a good host?
|| See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
||
Similar Threads
-
PHP to remove .com from name?
By kpmedia in forum Programming DiscussionReplies: 4Last Post: 09-20-2014, 06:39 PM -
How to remove php
By dtommy79 in forum VPS HostingReplies: 6Last Post: 04-06-2010, 07:17 AM -
Test your punctuation
By The Dude in forum Web Hosting LoungeReplies: 15Last Post: 09-22-2009, 02:28 PM -
deleting punctuation and special chars
By michael-lane in forum Programming DiscussionReplies: 3Last Post: 02-17-2006, 07:42 PM -
PHP Need to remove a . ?
By AskAR in forum Programming DiscussionReplies: 9Last Post: 12-01-2005, 07:07 PM