Text Size
Sunday, May 20, 2012
Get a look down
Drupal >> Items filtered by date: February 2012
Items filtered by date: February 2012

You can use this little snippet to scroll to the top of the page using javascript (in case you don't wan't to use html anchors)

1
2
3
<!-- The click on this link will take you to the top of the page -->
<!-- Place this link on the bottom of the page -->
<a href="#" onclick="window.scroll(); return false">Scroll to the top</a>
Published in Code snippets

Here's a little snippet that allow's us to remove any non alphanumeric characters from strings. It would be very usefull when a developper need to format a given string from a registration form for example.

1
2
3
4
5
6
7
8
9
10
<?php
// Our string
$words = "Hello! My Name Is Nabil SADKI 007!!!";
 
// Formatted string
$formatted_words = preg_replace("[^A-Za-z0-9]", "", $words ); // This will print : HelloMyNameIsNabilSADKI007
 
// Get only alpha
$formatted_words = preg_replace("[^A-Za-z]", "", $words ); // This will print : HelloMyNameIsNabilSADKI
?>
Published in Code snippets
Usefull tricks