<?php
/**
* Decode a string with encoded characters like &
* @param string encodedString - string to encode
* @return string
*/
function decodeEntities(encodedString) {
var textArea = document.createElement('textarea');
textArea.innerHTML = encodedString;
return textArea.value;
}
console.log(decodeEntities("Keith & Hards"));
output: "Keith & Hards"
Tuesday, 26 July 2016
How to decode encoded html entities in javascript:
Wednesday, 20 July 2016
Passing JSON into php function as a parameter
Here is an example of hot to pass JSON into a php function as a parameter:
<?php
function print_details($json) {
$args = json_decode($json);
echo "My first name is {$args->first_name}<br />";
echo "My last name is {$args->last_name}<br />";
echo "My age is {$args->age}<br />";
}
print_details('{
"first_name": "keith",
"last_name": "hards",
"age": 37
}');
Subscribe to:
Posts (Atom)