user3496349
user3496349

Reputation: 189

Flipping a Number Using PHP

Hi I have a number in php, and I need to flip it (eg. "1112"-->"2111"). How can this be performed? Should I use an array, or is there a special function?

Upvotes: 0

Views: 173

Answers (2)

Shijin TR
Shijin TR

Reputation: 7768

Using JAVASCRIPT

function strrev(str) 
 {  
  return str.split("").reverse().join(""); 
}  

alert(strrev("1112")); 

Using PHP

echo strrev("1112");

Upvotes: 0

Omer Arshad
Omer Arshad

Reputation: 520

You use the following strrev function in PHP.

$reverse = strrev("1112")

Upvotes: 3

Related Questions