Till death do us part
Axels New Music releases
Goth and Gore Gifts
Shop right now or else!
Viking gear
Gear Gifts and Apparel
Evil gear
Christmas is almost here

Search the script archive.

Enter a search term check the script type and click submit. To search for a general category for example to find all results for scripts working with text files or file manipulation enter file or curl. Same for directory, sql etc. Otherwise use specific terms.

Here is the script you requested.

scripts/search-string.txt: 559 bytes
How to search a string using substr and strlen and strstr two methods

search string strstr substr s
trlen
search-string date added Jan 2013

<?php
/**
 * StartsWith
 * Tests if a text starts with an g
iven str
ing.
 *
 * @param     string
 * @param     string
 * @return    bo
ol
 */
function StartsWi
th
($Haystack$Needle){
    
// Recommended 
versionusing strpos
    
return strpos($Haystack$Need
le
) === 0;
}

 
// Another way, using substr
function StartsWithOld($Haystack, $
Needle){ 
    
retur
n substr
($Haystack0strlen($Needle)) == $Needle
;
}

?>


Post a comment

No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl