replace all special character and multiple spaces with hyphon(-)

echo $string=’Google@stop#page!r$a.nk? Google: We Won\’t Be U$p%d^a&t*i(n)g T{o}o|l\b”a:r P;a`g~e                        Rank’;
echo “<br>”;
$ro = preg_replace(‘/\s+/’, ‘ ‘,$string);
echo strtolower(str_replace(array(‘  ‘, ‘ ‘), ‘-‘, preg_replace(‘/[^a-zA-Z0-9 s]/’, ‘ ‘, trim($ro))));

result :


Get previous url in php and javascript

//code for index.php

<a href=”previous-url.php”>click for php</a>
<a href=”previous-url-javascript.php”>click for javascript</a>

//code for previous-url.php


//code for previous-url-javascript.php

<button onclick=”goBack()”>Go 2 pages back</button>

<p>Notice that clicking on the “Go 2 pages back” button here will not result in any action, because there is no previous URL in the history list.</p>

function goBack() {