Force File Download: To get forceful downloads through the below code snippet makes it easier to attain online files using a web-based method or file reception process. Making online use to move towards a web-based method to have file access acquired with necessity through a code provided to you below. In addition, to create a tag cloud is to get the assurance of making an online collection of files that seem necessary and usable when saved using a tagging process defined in this code snippet. view plaincopy to clipboardprint? /******************** *@file - path to file */ function force_download($file) { if ((isset($file))&&(file_exists($file))) { header("Content-length: ".filesize($file)); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $file . '"'); readfile("$file"); } else { echo "No file selected"; } } Creating a Tag Cloud: view plaincopy to clipboardprint? function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 ) { $minimumCount = min($data); $maximumCount = max($data); $spread = $maximumCount - $minimumCount; $cloudHTML = ''; $cloudTags = array(); $spread == 0 && $spread = 1; foreach( $data as $tag => $count ) { $size = $minFontSize + ( $count - $minimumCount ) * ( $maxFontSize - $minFontSize ) / $spread; $cloudTags[] = '<a style="font-size: ' . floor( $size ) . 'px' . '" class="tag_cloud" href="#" title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars( stripslashes( $tag ) ) . '</a>'; } return join( "\n", $cloudTags ) . "\n"; } /************************** **** Sample usage ***/ $arr = Array('Actionscript' => 35, 'Adobe' => 22, 'Array' => 44, 'Background' => 43, 'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Color Palette' => 11, 'Crop' => 42, 'Delimiter' => 13, 'Depth' => 34, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30, 'Extract' => 28, 'Filters' => 42); echo getCloud($arr, 12, 36); Code Development Means in PHP Find Similarity between Two Strings: PHP arpatech has certain function similar_text occasionally usable but quite useful to compare with two strings as well as returns in percentage similarity between both. Comparing to find similarity between two given strings to see the comparativeness that needs assessment has important likes and dislikes that resonate with similarity existing within two strings under evaluation. view plaincopy to clipboardprint? similar_text($string1, $string2, $percent); //$percent will have the percentage of similarity Use Gravatars in Your Application: With ever-increasing popularity of WordPress, Gravatars have become quite popular. It is very easy to integrate them into your application as they provide a very easy to use API. view plaincopy to clipboardprint? /****************** *@email - Email address to show gravatar for *@size - size of gravatar *@default - URL of default gravatar to use *@rating - rating of Gravatar(G, PG, R, X) */ function show_gravatar($email, $size, $default, $rating) { echo '<img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5($email). '&default='.$default.'&size='.$size.'&rating='.$rating.'" width="'.$size.'px" height="'.$size.'px" />'; } PHP Development ways and Processes Truncate Text at Word Break: This function truncates certain strings only at word breaks with purpose to show a teaser when completing your article without breaking words within. To try to cut down certain words from within a sentence or a paragraph you want to use makes certain changes done with use of the code snippet shown below to complete your task. view plaincopy to clipboardprint? // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function myTruncate($string, $limit, $break=".", $pad="...") { // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; // is $break present between $limit and the end of the string? if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string; } /***** Example ****/ $short_string=myTruncate($long_string, 100, ' ');
3 Comments
10/15/2018 02:33:26 am
Obviously, the office of instructing of the objective dialect is given by the local speaker or the general population who are great in the objective dialect. Their involvement in that dialect is high. This office is additionally given by the objective nations.
Reply
3/27/2020 12:34:30 pm
PHP arpatech has certain function similar_text occasionally usable but quite useful to compare with two strings as well as returns in percentage similarity between both. Comparing to find similarity between two given strings to see the comparativeness that needs assessment has important likes and dislikes that resonate with similarity existing within two strings under evaluation.
Reply
5/17/2020 07:08:51 pm
I had a lot of new ideas when reading this post, it provided me very useful information. Thanks for this valuable information for all.
Reply
Leave a Reply. |