space between appended text

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Maltonjonas
Forum Newbie
Posts: 2
Joined: Fri Dec 10, 2010 5:21 am

space between appended text

Post 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
User avatar
ridgerunner
Forum Contributor
Posts: 214
Joined: Sun Jul 05, 2009 10:39 pm
Location: SLC, UT

Re: space between appended text

Post 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.
Maltonjonas
Forum Newbie
Posts: 2
Joined: Fri Dec 10, 2010 5:21 am

Re: space between appended text

Post 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 :)
User avatar
ridgerunner
Forum Contributor
Posts: 214
Joined: Sun Jul 05, 2009 10:39 pm
Location: SLC, UT

Re: space between appended text

Post 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]
Post Reply