- Posts: 3
- Thank you received: 0
General PHP Question - Showing only first Word
- Justin
- Topic Author
- Offline
- New Member
Less
More
11 years 9 months ago #17202
by Justin
General PHP Question - Showing only first Word was created by Justin
Hi, I am working on JoomDonation for my companies website, we have a what i wish program where our volunteer engineers will custom-design or modify items for people with disabilities. We are using this component to try to get support for each individual project (campaign) to support cost of this.
Anyway, what I am trying to do is take the Campaign Title:
<?php echo $item->title; ?> and alter this code to show only the first word out of the campaign title.
All Campaign's start with the child's name (Brennon's Swing, Yisroel's Voice Modulation Helper ) if I can figure out how to get Child's Name out of the title (the first word) i can then have the Donate Button say something like Help Make Brennon's Wish Come True. Right now all I can do is get it to show the entire campaign title.
If anyone could help me unlock this mystery (I don't know all that much coding) I would greatly appreciate it.
Justin
Anyway, what I am trying to do is take the Campaign Title:
<?php echo $item->title; ?> and alter this code to show only the first word out of the campaign title.
All Campaign's start with the child's name (Brennon's Swing, Yisroel's Voice Modulation Helper ) if I can figure out how to get Child's Name out of the title (the first word) i can then have the Donate Button say something like Help Make Brennon's Wish Come True. Right now all I can do is get it to show the entire campaign title.
If anyone could help me unlock this mystery (I don't know all that much coding) I would greatly appreciate it.
Justin
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
11 years 9 months ago #17239
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: General PHP Question - Showing only first Word
Hi
You can use explode function in PHP ( php.net/manual/en/function.explode.php ). The sample code for getting the first word could be :
Hope this help
Tuan
You can use explode function in PHP ( php.net/manual/en/function.explode.php ). The sample code for getting the first word could be :
Code:
$words = explode(' ', $item->title);
$firstWord = $words[0] ;
echo $firstWord ;
Hope this help
Tuan
The following user(s) said Thank You: Justin
Please Log in or Create an account to join the conversation.
- Justin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 9 months ago #17249
by Justin
Replied by Justin on topic Re: General PHP Question - Showing only first Word
Hi Tuan -
Thank you so much! Works like a champ!!! Great component, too!!!
Justin
Thank you so much! Works like a champ!!! Great component, too!!!
Justin
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
11 years 9 months ago #17257
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: General PHP Question - Showing only first Word
No problem Justin. I also answered your other question via support ticket. Please check the support ticket to see the detailed response .
Tuan
Tuan
Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam, Dũng Nguyễn Việt
Support
Documentation
Information
Copyright © 2024 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.