/    Sign up×
Community /Pin to ProfileBookmark

Reverse Title Order

Hi Guys

Is there a simple way to reverse the order of my title?

My title currently shows in the following format:
Accommodation | Hotels | Holiday Inn

I need it to show in the reverse order:
Holiday Inn | Hotels | Accommodation

Please also bear in mind that my site has approx. 20 000 pages, and the title for each page is called dynamically through:

[code=php]
<title><?php echo $page_title ?></title>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiAug 02.2009 — If you have these titles hard coded as strings and just want to reverse the items, this should work:

[code=php]$page_title = implode(' | ', array_reverse(explode(' | ', $page_title)));[/code]

But if you are getting these titles dynamically from somewhere like the session or a database then we'll need to see the code.
Copy linkTweet thisAlerts:
@AlvinSAauthorAug 02.2009 — You are an absolute genius! I've incorporated it into the code that calls my page title. Do you have any idea how many sites I've posted this question on, with no luck. I've been looking for 3 weeks now. Your code works flawlessly. THANK YOU!!!
×

Success!

Help @AlvinSA 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.18,
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,
)...