$subArray = array_slice($arr,0,4);
Get sub array in PHP
$subArray = array_slice($arr,0,4);
Based upon that snippet below using
preg_match() I needed something faster and less specific. That function
works and is brilliant but it scans the entire strings and checks that
it conforms to UTF-8
function detectUTF8($string)
{
return preg_match('%(?:
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|\xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|[\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|\xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)+%xs', $string);
}
Tooltips
in HTML pages general do not need any effort from a developer’s side,
as long as they put proper title attributes to their elements. The title
is then used for showing the tooltip, but also for other things, such
as providing a screen reader with proper content. Speaking of the use
case of tooltips, the visual presentation depends on the browser your
site gets visited with. Developers with the need for more control turned
to JavaScript bases solutions years ago. Kashagra Gour created
Hint.css, which proves as a decent alternative, based completely on CSS
and HTML.
Tooltips are a square deal. They allow for the placement of important
information just in the very location this information is needed,
regardless of screen real estate. Tooltipster is a plugin for jQuery
aiming at making the process of creating tooltips as easy as possible
while providing the biggest functionality available. They conform to
HTML5 and can be styled to your own liking using CSS.
<fieldset id="o-bs-sum-buginfo"> <label for="o-bs-sum-bug-ErrorPrefix">Error Prefix</label> <input type="text" id="o-bs-sum-bug-ErrorPrefix" name="ErrorPrefix" value="" /> <label for="o-bs-sum-bug-ErrorNumber">Error Number</label> <input type="text" id="o-bs-sum-bug-ErrorNumber" name="ErrorNumber" value="" /> .... </fieldset>
label{ float:left; width:100px; //whatever width that suits your needs } p{ margin:10px 0; //manipulate the vertical spaces for each input.. } <fieldset > <p> <label for="o-bs-sum-bug-ErrorPrefix">Error Prefix</label> <input type="text" name="ErrorPrefix" value="" /> </p> </fieldset>
by Unknown in javascript , jquery 0
$('form').bind("keypress", function(e) { if (e.keyCode == 13) { e.preventDefault(); return false; } });
$("form :input").on("keypress", function(e) { return e.keyCode != 13; });
Is there a way to get the size of a remote file http://my_url/my_file.txt without downloading the file?
Solution:
<?php/** * Returns the size of a file without downloading it, or -1 if the file * size could not be determined. * * @param $url - The location of the remote file to download. Cannot * be null or empty. * * @return The size of the file referenced by $url, or -1 if the size * could not be determined. */function curl_get_file_size( $url ) { // Assume failure. $result = -1; $curl = curl_init( $url ); // Issue a HEAD request and follow any redirects. curl_setopt( $curl, CURLOPT_NOBODY, true ); curl_setopt( $curl, CURLOPT_HEADER, true ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $curl, CURLOPT_USERAGENT, get_user_agent_string() ); $data = curl_exec( $curl ); curl_close( $curl ); if( $data ) { $content_length = "unknown"; $status = "unknown"; if( preg_match( "/^HTTP\/1\.[01] (\d\d\d)/", $data, $matches ) ) { $status = (int)$matches[1]; } if( preg_match( "/Content-Length: (\d+)/", $data, $matches ) ) { $content_length = (int)$matches[1]; } // http://en.wikipedia.org/wiki/List_of_HTTP_status_c... if( $status == 200 || ($status > 300 && $status <= 308) ) { $result = $content_length; } } return $result;}?>Usage:
$file_size = curl_get_file_size( "http://abc.com/questions/2602612/php-remote-file-size-without-downloading-file" );
Source:PHP: Remote file size without downloading file