Page 1 of 1

space between appended text

Posted: Fri Dec 10, 2010 5:26 am
by Maltonjonas
I am trying to join two keywords with a space in the middle. So far I have:

echo'<meta name="description" content="';
$keywordtitle = keyword();
$descriptitle = meta_title();
$description = $keywordtitle.$descriptitle.'">';
echo $description;

Everything I have tried so far tends to put the space at the end rather than the middle of the sentence leaving the two keywords joined together. How to I separate the two outputs with a space to get something like:

<content=”Stand up for your rights”>

Instead of:
<content=”Stand upfor your rights ”>

thanks

Re: space between appended text

Posted: Fri Dec 10, 2010 9:58 am
by ridgerunner
Maltonjonas wrote:... Everything I have tried so far tends to ...
What, exactly, have you tried so far? Please provide more detailed information - your post as written, does not explain your problem very well and I can see no specific regex question.

Re: space between appended text

Posted: Fri Dec 10, 2010 10:49 am
by Maltonjonas
Intent:
-------
To create a meta description by concatenating two string variables.


Problem:
---------
Strings concatenates but there is no space between the two string. Last word of the first string and the first word of the last string are joinedtogether <-- like so


Ideally I would like to see:
---------------------------
A solution demonstrating how to concatenate the two string so that the last word of the first string and the first word of the last string are not joined together <-- like so


My attempts have included:
----------------------------
$description = $keywordtitle."\s".$descriptitle.'">';
$description = $keywordtitle.'" "'.$descriptitle.'">';
$description = $keywordtitle.' '.$descriptitle.'">';

thanks :)

Re: space between appended text

Posted: Fri Dec 10, 2010 7:03 pm
by ridgerunner
Looks to me like your last two should work just fine. Here is a script that works...

Code: Select all

<?php
echo'<meta name="description" content="';
$keywordtitle = 'keyword';
$descriptitle = 'title';
$description = $keywordtitle.' '.$descriptitle.'">';
echo $description;
?>
This script gives the following output:
[text]<meta name="description" content="keyword title">[/text]