Posts Tagged ‘Scripts’

How to Remove Characters Except Numbers from a String ?

September 15, 2011 Leave a comment

Following Code will remove all character,special characters including space.


$givenNumber = “1245fdfd8454D FDFDF434 3$#$#%”;

$testingNumber = preg_replace(‘[\D]‘, ”, $givenNumber);

echo $testingNumber;

Output is : 124584544343



How to Translate Text to desired language ?

September 15, 2011 Leave a comment

Just follow these steps and copy & paste the code you can translate text easily.

Step 1 : Make a div with id (id is compulsory)
Like <div id="content">Loading…</div>

Step 2 : Paste the following code to head section under script tag of your webpage.
google.load(“language”, “1″);

function initialize() {
var content = document.getElementById(‘content’);
// Setting the text in the div.
content.innerHTML = ‘<div id=”text”>Place Your Text Here (Hola, me alegro mucho de verte.)<\/div><div id=”translation”/>’;

// Grabbing the text to translate
var text = document.getElementById(“text”).innerHTML;

// Translate from Spanish to English, and have the callback of the request
// put the resulting translation in the “translation” div.
// Note: by putting in an empty string for the source language (‘es’) then the translation
// will auto-detect the source language.
google.language.translate(text, ‘es’, ‘en’, function(result) {
var translated = document.getElementById(“translation”);
if (result.translation) {
translated.innerHTML = result.translation;

Step 3 : And the final Step is paste the following URL in src of script tag.

Above example is translating Spanish to English You can translate as your choice.
Just change the code in
google.language.translate(text, ‘es’, ‘en’, function(result)
es stands for Spanish,
en stands for English
You can find more language code at

%d bloggers like this: