This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Source: http://www.apphp.com/index.php?snippet=php-list-directory-contents */ | |
| function list_directory_content($dir){ | |
| if(is_dir($dir)){ | |
| if($handle = opendir($dir)){ | |
| while(($file = readdir($handle)) !== false){ | |
| if($file != '.' && $file != '..' && $file != '.htaccess'){ | |
| echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n"; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Source: http://www.apphp.com/index.php?snippet=php-download-file-with-speed-limit */ | |
| /* set here a limit of downloading rate (e.g. 10.20 Kb/s) */ | |
| $download_rate = 10.20; | |
| $download_file = 'download-file.zip'; | |
| $target_file = 'target-file.zip'; | |
| if(file_exists($download_file)){ | |
| /* headers */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Source: http://www.apphp.com/index.php?snippet=php-parsing-xml-file */ | |
| // this is a sample xml string | |
| $xml_string="<?xml version='1.0'?> | |
| <text> | |
| <article id='Article1'> | |
| <title>Title 1</title> | |
| <content>..text here..</content> | |
| </article> | |
| <article id='Article2'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Source: http://www.apphp.com/index.php?snippet=php-remove-duplicates-in-array */ | |
| $input = array("a"=>"apple", "pear", "b"=>"apple", "orange", "avocado", "banana"); | |
| print_r($input); | |
| $result = array_unique($input); | |
| print_r($result); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-toggle-elements */ | |
| function toggle(id, id2){ | |
| var toggle_one = document.getElementById(id); | |
| var toggle_two = document.getElementById(id2); | |
| if(toggle_one.style.display == "block"){ | |
| toggle_one.style.display = "none"; | |
| toggle_two.innerHTML = "Show"; | |
| }else{ | |
| toggle_one.style.display = "block"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-pass-parameters-in-setinterval */ | |
| // sample #1 | |
| setInterval('alert_function(1)', 1500); | |
| // sample #2 | |
| setInterval(function(){ alert_function(10); }, 1500); | |
| // user's alert function | |
| function alert_function(val){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Sample #1: form button --> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-close-window */ | |
| <form> | |
| <input type=button value="Close This Window" onclick="javascript:window.close();"> | |
| </form> | |
| <!-- Sample #2: text link --> | |
| <a href="javascript:window.close();">Click Here to Close Window</a> | |
| <!-- Sample #3: close window after a given number of seconds --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-email-validation */ | |
| function check_email(email){ | |
| var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | |
| if(reg.test(email)){ | |
| return true; | |
| }else{ | |
| return false; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style type="text/css"> | |
| /* Source: http://www.apphp.com/index.php?snippet=css-box-shadow */ | |
| .shadow { | |
| -moz-box-shadow: 4px 5px 5px 1px #777; | |
| -webkit-box-shadow: 4px 5px 5px 1px #777; | |
| box-shadow: 4px 5px 5px 1px #777; | |
| } | |
| .shadowIE { | |
| background-color:#f5f5f5; /* need for IE*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| /* Source: http://www.apphp.com/index.php?snippet=css-background-gradient */ | |
| .grad{ | |
| background: -webkit-gradient(linear, left top, left bottom, from(#84c8d7), to(#327fbd)); | |
| background: -moz-linear-gradient(top, #84c8d7, #327fbd); | |
| filter: | |
| progid:DXImageTransform.Microsoft.gradient(startColorstr="#84c8d7", endColorstr="#327fbd"); | |
| } | |
| </style> | |