sitNsmile
03-19-2010, 03:26 PM
Separate words in example, title.
Game Name = Rally Point
(i want to take that it also have the system show me)
"Rally Games | Point Games"
anyone know how to separate words in a title (that's grabbed from the database, and i'll add the word 'games' at the end of each.)
Thanks
MattF
03-19-2010, 03:34 PM
$string = 'some words';
$string = implode(' Games |', explode(' ', $string)).' Games';
sitNsmile
03-19-2010, 03:41 PM
$string = 'some words';
$string = implode(' Games |', explode(' ', $string)).' Games';
Thank you, That worked perfect.
but to add to that, is there a way of making it so that I can wrap a <a link on each one.. example
<a> Rally Games </a> | <a> Point Games</a>
<a h=www.rally.com>Rally Games</a> | <a h=www.point.com>Point Games</a>
Thanks
sitNsmile
03-19-2010, 04:20 PM
Main concept im trying to accomplish is define both words as separate. Above is a start.
"Rally = $word1" and "Point = $word2"
So that they can be sent to a different URL and I can use those words. Hope that makes sense. Ideas?
Thanks
MattF
03-19-2010, 04:45 PM
$links = array();
$string = 'Rally Point';
$words = explode(' ', $string);
foreach ($words as $word)
{
$links[] = '<a href="[uri here]">'.$word.' Games</a>';
}
$string = implode(' | ', $links);
Edit: If the URI domain name is always the word, you could change the $links[] line to:
$links[] = '<a href="http://'.strtolower($word).'.com">'.$word.' Games</a>';