Hi,
how to reverse first name and last name of string in dynamically.
ex:
input:: hello php world
output:: world php hello

Recommended Answers

Answered by diafol 3,720 in a post from

OK, such a trivial one. BUt u should show some effort yourself. What did you try? Clue:

explode : array_reverse : implode : echo
Jump to Post

All 3 Replies

perhaps explode then echo in reverse

<?php 
$hello  = "hello world";
$part = explode(" ", $hello);
echo $part [1]; // piece1
echo $part [0]; // piece2
?>
Member Avatar

OK, such a trivial one. BUt u should show some effort yourself. What did you try? Clue:

explode : array_reverse : implode : echo
commented: Thnk you +0

love learning.array_reverse, thats neat

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.