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

Recommended Answers

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 for diafol

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, networking, learning, and sharing knowledge.