/    Sign up×
Community /Pin to ProfileBookmark

printing a fixed value between 2 variables

Hi,

i am trying to print something like this:

print “$date1[COLOR=”Red”]PM[/COLOR]$date2″

The PM is a fixed value that comes between the 2 variables and there must be no spaces separating them from each other when printed so it should look like this:

[CODE]8PM7[/CODE]

I just would like to ask what separator should i use so the variables are parsed correctly.

Thank you.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 04.2010 — Either concatenate or use "complex notation":
[code=php]
print $date1 . "PM$date2";
print "{$date1}PM$date2";
[/code]

Or you could use printf():
[code=php]
printf("%sPM%s", $date1, $date2);
[/code]
Copy linkTweet thisAlerts:
@supercainauthorMay 04.2010 — Thank you man, that was really helpful and fast. Now i remember i used to know about this one {$date1} but i just had forgotten about it.
×

Success!

Help @supercain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...