Niouzes

< Mai 2018 >
Lu Ma Me Je Ve Sa Di
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Citation

Attention

The documentation is incomplete. The Vae Soli! team works hard to make it as exhaustive as possible with tons of useful examples and easy to understand explanations.

On top of that, we have decided to use our own tool to generate the documentation you read. This also takes time to fine-tune. Our goal is have better documentation, easier to read, easier to use, completely integrated with our site.

Even though NOT finalized, you can now link back to our documentation pages as we have decided once and for all about the structure of our documents and where they all reside on our server.

Thank you very much
The Vae Soli! team.

2018-05-20 à 07:15:18

Table Of Contents

  1. FOUNDATION (functions) (01/04/2015)
  2. LSAction (class) (01/04/2015)
  3. LSAddress (class) (01/04/2015)
  4. LSAdministrativeArea (class) (01/04/2015)
  5. LSApplication (class) (14/10/2013)
  6. LSArray (class) (14/10/2013)
  7. LSArticle (class) (18/02/2014)
  8. LSAssertion (class) (14/10/2013)
  9. LSAudience (class) (18/02/2014)
  10. AUTOLOAD (function) (21/04/2014)
  11. LSAutoReference (class) (14/10/2013)
  12. LSBag (class) (14/10/2013)
  13. LSBBCodes (class) (10/06/2014)
  14. LSBrowser (class) (14/10/2013)
  15. LSCache (class) (14/10/2013)
  16. LSCalculator (class) (14/10/2013)
  17. LSCalendar (class) (14/10/2013)
  18. LSCameraSnapshot (class) (14/10/2013)
  19. LSCitation (class) (14/10/2013)
  20. LSClass (class) (14/10/2013)
  21. LSCode (class) ()
  22. Colors (functions) (20/05/2018)
  23. LSContactForm (class) (14/10/2013)
  24. LSContainer (class) (14/10/2013)
  25. LSContents (class) (14/10/2013)
  26. LSContentsAccounts (class) (14/10/2013)
  27. LSContentsArticles (class) (14/10/2013)
  28. LSContentsAtomicClock (class) (14/10/2013)
  29. LSContentsBusinessCoordinates (class) (14/10/2013)
  30. LSContentsBusinessOff (class) (14/10/2013)
  31. LSContentsBusinessOpeningHours (class) (14/10/2013)
  32. LSContentsBreadcrumb (class) (14/10/2013)
  33. LSContentsCalendar (class) (14/10/2013)
  34. LSContentsCatalogue (class) (14/10/2013)
  35. LSContentsCharter (class) (18/02/2014)
  36. LSContentsCitation (class) (14/10/2013)
  37. LSContentsClock (class) (14/10/2013)
  38. LSContentsComments (class) (14/10/2013)
  39. LSContentsCookieUsage (class) (14/10/2013)
  40. LSContentsCountdown (class) (14/10/2013)
  41. LSContentsDatetime (class) (14/10/2013)
  42. LSContentsHeartbeat (class) (14/10/2013)
  43. LSContentsIFrame (class) (14/10/2013)
  44. LSContentsImageGallery (class) (14/10/2013)
  45. LSContentsLanguageSwitchers (class) (14/10/2013)
  46. LSContentsLegal (class) (18/02/2014)
  47. LSContentsMicronews (class) (14/10/2013)
  48. LSContentsMyAccount (class) (14/10/2013)
  49. LSContentsPaymentOptions (class) (14/10/2013)
  50. LSContentsPinboard (class) (14/10/2013)
  51. LSContentsRememberPassword (class) (14/10/2013)
  52. LSContentsRSS (class) (14/10/2013)
  53. LSContentsSiteManager (class) (14/10/2013)
  54. LSContentsSitemap (class) (14/10/2013)
  55. LSContentsShare (class) (14/10/2013)
  56. LSContentsStopwatch (class) (14/10/2013)
  57. LSContentsTagCloud (class) (14/10/2013)
  58. LSContentsTodosOnPage (class) (14/10/2013)
  59. LSContentsW3C (class) (14/10/2013)
  60. LSContentsWeather (class) (14/10/2013)
  61. LSControl (class) (14/10/2013)
  62. LSCreativeWork (class) (18/02/2014)
  63. LSCursor (class) (09/03/2015)
  64. LSCustomer (class) (14/10/2013)
  65. LSDataEnvironment (class) (14/10/2013)
  66. Dates (functions) (01/04/2015)
  67. LSDate (class) (14/10/2013)
  68. LSDictionary (class) (14/10/2013)
  69. LSDom, LSDomNode and LSXPath (class) (30/04/2014)
  70. LSErrors and LSError (classes) (14/10/2013)
  71. LSException (class) (16/10/2013)
  72. LSExplorer (class) (14/10/2013)
  73. LSFieldset (class) (14/10/2013)
  74. LSFile (class) (14/10/2013)
  75. LSFileProperties (class) (14/10/2013)
  76. Files (functions) (01/04/2015)
  77. Finance (functions) (01/04/2015)
  78. LSFootnotes (class) (22/02/2014)
  79. LSForm (class) (09/06/2014)
  80. LSFunction (class) (14/10/2013)
  81. LSGeorama (class) (24/10/2013)
  82. LSGeoramaVar (class) (24/10/2013)
  83. LSGlossary (class) (09/03/2015)
  84. LSGroup (class) (14/10/2013)
  85. HTML (functions) (01/04/2015)
  86. LSHttp (class) (14/10/2013)
  87. HTTP (functions) (01/04/2015)
  88. LSImageGallery (class) (14/10/2013)
  89. Images (functions) (01/04/2015)
  90. LSInput (class) (26/04/2014)
  91. IP (functions) (01/04/2015)
  92. LSIslandAbstract (14/10/2013)
  93. LSIslandFormAbstract (class) (14/10/2013)
  94. LSLabel (class) (14/10/2013)
  95. LSLanguageSwitchers (class) (14/10/2013)
  96. LSLatin (class) (14/10/2013)
  97. LSLegalPerson (class) (14/10/2013)
  98. LSLinkedList (class) (14/10/2013)
  99. LSList (class) (14/10/2013)
  100. Mails (functions) (01/04/2015)
  101. LSMap (class) (14/10/2013)
  102. Math (functions) (01/04/2015)
  103. LSMicronews (class) (18/02/2014)
  104. Miscellaneous (functions) (01/04/2015)
  105. LSModuleAbstract (class) (14/10/2013)
  106. LSNaturalPerson (class) (14/10/2013)
  107. LSNewsArticle (class) (18/02/2014)
  108. LSNote (class) (14/10/2013)
  109. LSMotherNature (class) (16/10/2013)
  110. LSPage (class) (18/02/2014)
  111. LSParameter (class) (14/10/2013)
  112. LSPaymentOptions (class) (14/10/2013)
  113. LSPeopleAudience (class) (18/02/2014)
  114. LSPerson (class) (14/10/2013)
  115. LSPlace (class) (18/02/2014)
  116. LSProperty (class) (14/10/2013)
  117. LSPublication (class) (14/10/2013)
  118. LSRequirement (class) (14/10/2013)
  119. LSReturn (class) (24/10/2013)
  120. LSRisk (class) (14/10/2013)
  121. LSSentanaiAbstract (14/10/2013)
  122. LSServiceMessage (class) (14/10/2013)
  123. LSSession (class) (14/10/2013)
  124. LSSiteManager (class) (14/10/2013)
  125. LSSitemap (class) (14/10/2013)
  126. LSSockets (class) (14/10/2013)
  127. LSSoftwareApplication (class) (18/02/2014)
  128. LSSource (class) (14/10/2013)
  129. Strings (functions) (31/07/2016)
  130. LSSupplier (class) (14/10/2013)
  131. System (functions) (01/04/2015)
  132. LSTag (class) (21/04/2014)
  133. LSTagCloud (class) (14/10/2013)
  134. LSTechArticle (class) (18/02/2014)
  135. LSThing (class) (18/02/2014)
  136. LSTimeline (class) (14/10/2013)
  137. LSTimer (class) (16/10/2013)
  138. LSTracer (class) (09/03/2015)
  139. LSUnitTesting (class) (14/10/2013)
  140. URL (functions) (01/04/2015)
  141. LSUser (class) (09/03/2015)
  142. LSUserMgr (class) (14/10/2013)
  143. LSVaesoli (class) (09/06/2014)
  144. LSVersion (class) (14/10/2013)
  145. LSWebSite (class) (14/10/2013)
  146. LSWidget (class) (14/10/2013)
  147. LSWireTransferForm (class) (14/10/2013)
  148. LSXMLSitemap (class) (14/10/2013)
  149. XML (functions) (01/04/2015)

LSStrings.functions.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 31-07-2016 02:10:22 (DD-MM-YYYY HH:mm:SS). This documentation is built with Vae Soli! functions and classes!

The download page of Vae Soli! contains all sources of the framework.

Additional samples are available on the samples page of Vae Soli!.

File Properties

D:\websites\vaesoli.org\www\httpdocs/vaesoli/include/LSStrings.functions.phpD:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSStrings.functions.phpapplication/force-downloadD:\websites\vaesoli.org\www\httpdocs\vaesoli\include232293 bytes09/03/2016 08:53:1722/07/2016 09:28:2309/03/2016 08:53:17

Compliance

Assertions count: 219

Assertions successful: 202

Assertion failures: 17

Early Warning

LSStrings.functions.php exceeds 51200 bytes. We suggest this file got broken down in smaller chunks!

LSStrings.functions.php contains 6409 lines of code, which exceeds the suggested limit of 1024 lines. We suggest this file got broken down in smaller chunks!

0001 ... <?php
0002 ... /**************************************************************************/
0003 ... /** {{{*fheader (lang=en)
0004 ...     {*file                  LSString.functions.php *}
0005 ...     {*purpose               String functions *}
0006 ...     {*author                 *}
0007 ...     {*company               [br]Lato Sensu Management[br]
0008 ...                             Rue Bois des Mazuis, 47[br]
0009 ...                             5070 Vitrival[br]
0010 ...                             Belgium (BE)[br]
0011 ...                             [url]http://www.latosensu.be[/url][br]
0012 ...                             Vae Soli! : [url]http://www.vaesoli.org[/url]
0013 ...     *}
0014 ...     {*cdate                 16/08/2006 - 12:31 *}
0015 ...     {*mdate                 auto *}
0016 ...     {*license               [url]http://creativecommons.org/licenses/by-sa/2.0/be/[/url][br]
0017 ... 
0018 ...                             To obtain detailed information about the license
0019 ...                             terms, please head to the full license text
0020 ...                             available in the [file]LSCopyright.php[/file] file
0021 ...     *}
0022 ... 
0023 ...     ------------------------------------------------------------------------
0024 ...     Changes History:        Everything before the 13th of April 2006 has
0025 ...                             NOT been documented.
0026 ... 
0027 ...     [include]C:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSStrings.functions.journal[/include]
0028 ... 
0029 ... 
0030 ... *}}}
0031 ... /**************************************************************************/
0032 ... if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) )
0033 ... {
0034 ...     /* {*define (LS_STRINGS_FUNCTIONS)  Remember that THESE functions have been declared *} */
0035 ...     define( 'LS_STRINGS_FUNCTIONS','PWH' );
0036 ... }   /* if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) ) */
0037 ... 
0038 ... if ( ! defined( 'VAESOLI_PATH' ) )
0039 ... {
0040 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0041 ...     define( 'VAESOLI_PATH',__DIR__ );
0042 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0043 ... 
0044 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )
0045 ... {
0046 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0047 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0048 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0049 ... 
0050 ... /* {*require (LSStrings.inc)                String constants *} */
0051 ... require_once( VAESOLI_PATH . '/LSStrings.inc' );
0052 ... /* {*require (LIB_parse.php)                Parsing lib (NOT Vae Soli!) *} */
0053 ... require_once( VAESOLI_PATH . '/WebBots/LIB_parse.php'    );
0054 ... /* {*require (LSUnitTesting.class.php)      Vae Soli! Unit Testing *} */
0055 ... require_once( VAESOLI_PATH . '/LSUnitTesting.class.php'   );
0056 ... 
0057 ... 
0058 ... /* ========================================================================== */
0059 ... /** {{*STR_StripTags( $szString,$bComments )=
0060 ... 
0061 ...     Strip tags but potentially leave comments
0062 ... 
0063 ...     {*params
0064 ...         $szString   (string)    String to process.
0065 ...         $bComments  (bool)      Optional. [c]true[/c] by default, in which case
0066 ...                                 comments will NOT be removed. Use [c]false[/c]
0067 ...                                 to remove the HTML/XML comments.
0068 ...     *}
0069 ... 
0070 ...     {*return
0071 ...         (string)    $szString where all tags were removed, potentially accepting
0072 ...                     the comments (default behavior)
0073 ...     *}
0074 ... 
0075 ...     {*author  *}
0076 ...     {*cdate 03/02/2015 11:29 *}
0077 ... 
0078 ...     {*example
0079 ...         echo STR_StripTags( "<html><head><title>My page</title></head></html>" );
0080 ...         // 'My page'
0081 ...     *}
0082 ... 
0083 ...     {*assert
0084 ...         STR_StripTags( "<html><head><title>My page</title></head><body><!-- My comment --></body></html>" ) === 'My page<!-- My comment -->'
0085 ...     *}
0086 ... 
0087 ...     {*assert
0088 ...         STR_StripTags( "<html><head><title>My page</title></head><body><!-- My comment --></body></html>",false ) === 'My page'
0089 ...     *}
0090 ... 
0091 ...     {*seealso
0092 ...         STR_StripPHPTags(), STR_RemovePHPComments()
0093 ...     *}
0094 ... 
0095 ...     *}}
0096 ...  */
0097 ... /* ========================================================================== */
0098 ... function STR_StripTags( $szStr,$bComments = true )
0099 ... /*----------------------------------------------*/
0100 ... {
0101 ...     return ( preg_replace( '%</?[a-z][a-z0-9]*[^<>]*>' . ( $bComments ? '' : '|<!--.*?-->' ).'%sim','',$szStr ) );
0102 ... }   /* == End of function STR_StripTags() =================================== */
0103 ... 
0104 ... function STR_FormatHTML( $szStr )
0105 ... /*-----------------------------*/
0106 ... {
0107 ...     $szRetVal = preg_replace( '%</(p|h\d{1})>([ \r\n]*)<(p|h\d{1à}|[ou]l)>%sim',"</\1>\n\n</\3>",$szStr );
0108 ... 
0109 ...     return ( $szRetVal );
0110 ... }
0111 ... 
0112 ... /* ========================================================================== */
0113 ... /** {{*STR_RemovePHPComments( $szStr )=
0114 ... 
0115 ...     Remove PHP Comments from a string (which is supposed to be PHP Code)
0116 ... 
0117 ...     {*params
0118 ...         $szStr  (string)    String to process.
0119 ...     *}
0120 ... 
0121 ...     {*return
0122 ...         (string)    $szStr where all PHP comments have been removed
0123 ...     *}
0124 ... 
0125 ...     {*author  *}
0126 ...     {*cdate 01/04/2015 08:57 *}
0127 ... 
0128 ...     {*exec
0129 ...         $szSrc      = 'C:/websites/vaesoli.org/www/httpdocs/vaesoli/include/LSStrings.functions.php';
0130 ...         $szCode     = file_get_contents( $szSrc );
0131 ...         $szClean    = STR_RemovePHPComments( $szCode );
0132 ... 
0133 ...         if ( defined( 'T_DOC_COMMENT' ) )
0134 ...         {
0135 ...             $aCommentTokens[] = T_DOC_COMMENT; // PHP 5
0136 ...         }
0137 ...         if ( defined( 'T_ML_COMMENT'  ) )
0138 ...         {
0139 ...             $aCommentTokens[] = T_ML_COMMENT;  // PHP 4
0140 ...         }
0141 ... 
0142 ...         $aCodeTokens = token_get_all( $szClean );
0143 ...         $bFoundComments = false;
0144 ... 
0145 ...         foreach ( $aCodeTokens as $token )
0146 ...         {
0147 ...             if ( is_array( $token ) )
0148 ...             {
0149 ...                 if ( in_array( $token[0],$aCommentTokens ) )
0150 ...                 {
0151 ...                     $bFoundComments = true;
0152 ...                     var_dump( $token );
0153 ...                     break;
0154 ...                 }
0155 ...             }
0156 ...         }
0157 ... 
0158 ...         echo LSUnitTesting::assert( ! $bFoundComments                                       ,
0159 ...                                     'ASSERTION SUCCESSFUL: all comments seem to be removed' ,
0160 ...                                     'ASSERTION FAILURE: there are still comments!'          ,
0161 ...                                     'GuideAssert' );
0162 ...     *}
0163 ... 
0164 ...     {*seealso
0165 ...         STR_StripPHPTags(), STR_StripTags()
0166 ...     *}
0167 ... 
0168 ...     *}}
0169 ...  */
0170 ... /* ========================================================================== */
0171 ... function STR_RemovePHPComments( $szStr )
0172 ... /*------------------------------------*/
0173 ... {
0174 ...     $szRetVal  = '';
0175 ... 
0176 ...     //echo "<p>LENGTH BEFORE: ",strlen( $szStr ),"</p>\n";
0177 ... 
0178 ...     $aCommentTokens = array( T_COMMENT );
0179 ... 
0180 ...     if ( defined( 'T_DOC_COMMENT' ) )
0181 ...     {
0182 ...         $aCommentTokens[] = T_DOC_COMMENT; // PHP 5
0183 ...     }
0184 ...     if ( defined( 'T_ML_COMMENT'  ) )
0185 ...     {
0186 ...         $aCommentTokens[] = T_ML_COMMENT;  // PHP 4
0187 ...     }
0188 ... 
0189 ...     $aCodeTokens = token_get_all( $szStr );
0190 ... 
0191 ...     foreach ( $aCodeTokens as $token )
0192 ...     {
0193 ...         if ( is_array( $token ) )
0194 ...         {
0195 ...             if ( in_array( $token[0],$aCommentTokens ) )
0196 ...             {
0197 ...                 continue;
0198 ...             }
0199 ... 
0200 ...             $token = $token[1];
0201 ...         }
0202 ... 
0203 ...         $szRetVal .= $token;
0204 ...     }
0205 ... 
0206 ...     //echo "<p>LENGTH AFTER: ",strlen( $szRetVal ),"</p>\n";
0207 ... 
0208 ...     return ( $szRetVal );
0209 ... }
0210 ... 
0211 ... /* ========================================================================== */
0212 ... /** {{*STR_StripPHPTags( $szString )=
0213 ... 
0214 ...     Strip PHP tags
0215 ... 
0216 ...     {*params
0217 ...         $szString   (string)    String to process.
0218 ...     *}
0219 ... 
0220 ...     {*return
0221 ...         (string)    $szString where all PHP tags were removed
0222 ...     *}
0223 ... 
0224 ...     {*author  *}
0225 ...     {*cdate 03/02/2015 11:52 *}
0226 ... 
0227 ...     {*assert
0228 ...         STR_StripPHPTags( "&lt;?php echo 'Hello'; ?&gt;" ) === ''
0229 ...     *}
0230 ... 
0231 ...     {*seealso
0232 ...         STR_StripTags(), STR_RemovePHPComments()
0233 ...     *}
0234 ...     *}}
0235 ...  */
0236 ... /* ========================================================================== */
0237 ... function STR_StripPHPTags( $szStr )
0238 ... /*-------------------------------*/
0239 ... {
0240 ...     return ( preg_replace( '/&lt;\?php(.*?)\?&gt;/sim','',$szStr ) );
0241 ... }   /* == End of function STR_StripPHPTags() ================================ */
0242 ... 
0243 ... /* ========================================================================== */
0244 ... /** {{*STR_Peek( $szString,$iPosition )=
0245 ... 
0246 ...     Returns the ASCII code of a given character in a string.
0247 ... 
0248 ...     {*params
0249 ...         $szString   (string)    String to process.
0250 ...         $iPosition  (int)       Position in string ($szString) to examine
0251 ...     *}
0252 ... 
0253 ...     {*return
0254 ...         (int)   ASCII code value of the character found at $iPosition in
0255 ...                 $szString.
0256 ...     *}
0257 ... 
0258 ...     {*author  *}
0259 ...     {*cdate 19/09/2013 19:15 *}
0260 ... 
0261 ...     {*example
0262 ...         echo STR_Peek( "Hello",0 );     // 72 because 'H' is 72 ASCII
0263 ...     *}
0264 ... 
0265 ...     {*assert
0266 ...         STR_Peek( "Hello",0 ) === 72
0267 ...     *}
0268 ... 
0269 ...     {*seealso
0270 ...         STR_Poke()
0271 ...     *}
0272 ...     *}}
0273 ...  */
0274 ... /* ========================================================================== */
0275 ... function STR_Peek( $szString,$iPosition )
0276 ... /*-------------------------------------*/
0277 ... {
0278 ...     return ( ord( $szString[$iPostion] ) );
0279 ... }   /* == End of function STR_Peek() ======================================== */
0280 ... 
0281 ... /* ========================================================================== */
0282 ... /** {{*STR_Poke( $szString,$iPosition,$iCode )=
0283 ... 
0284 ...     Poke a character at given position in a string.
0285 ... 
0286 ...     {*params
0287 ...         $szString   (string)    string to process.
0288 ...         $iPosition  (int)       position in string ($szString) to poke
0289 ...         $iCode        (int)       code to stuff at the proper position
0290 ...     *}
0291 ... 
0292 ...     {*return
0293 ...         (string)    Resulting string
0294 ...     *}
0295 ... 
0296 ...     {*author  *}
0297 ...     {*cdate 19/09/2013 19:15 *}
0298 ... 
0299 ...     {*example
0300 ...         $szString = "Hello";
0301 ...         echo STR_poke( $szString,1,97 );    // "Hallo"
0302 ...         echo $szString;                     // "Hello"
0303 ...     *}
0304 ... 
0305 ...     {*assert
0306 ...         STR_poke( 'Hello',1,97 ) === 'Hallo'
0307 ...     *}
0308 ... 
0309 ...     {*seealso
0310 ...         STR_Peek()
0311 ...     *}
0312 ... 
0313 ...     *}}
0314 ...  */
0315 ... /* ========================================================================== */
0316 ... function STR_Poke( $szString,$iPosition,$iCode )
0317 ... /*-------------------------------------------*/
0318 ... {
0319 ...                                $szString[$iPosition] = chr( $iCode );
0320 ...     return ( $szString );
0321 ... }   /* == End of function STR_Poke() ======================================== */
0322 ... 
0323 ... /* ========================================================================== */
0324 ... /** {{*STR_PasswordStrength( $szPwd )=
0325 ... 
0326 ...     Checks the strength of a password
0327 ... 
0328 ...     {*params
0329 ...         $szPwd  (string)    The password to check
0330 ...     *}
0331 ... 
0332 ...     {*return
0333 ...         (int)   A strength index (0 = very weak; 10 = strong)
0334 ...     *}
0335 ... 
0336 ...     {*author  *}
0337 ...     {*cdate 06/08/2013 08:15 *}
0338 ... 
0339 ...     *}}
0340 ...  */
0341 ... /* ========================================================================== */
0342 ... function STR_PasswordStrength( $szPwd )
0343 ... /*-----------------------------------*/
0344 ... {
0345 ...     $iLength    = strlen( $szPwd );
0346 ...     $iScore     = 0;
0347 ... 
0348 ...     if ( is_string( $szPwd ) )
0349 ...     {
0350 ...         if ( $iLength < 6 )
0351 ...         {
0352 ...             return ( $iScore );
0353 ...         }
0354 ... 
0355 ...         if ( $iLength >= 8 )
0356 ...         {
0357 ...             $iScore++;
0358 ...         }
0359 ... 
0360 ...         if ( $iLength >= 10 )
0361 ...         {
0362 ...             $iScore++;
0363 ...         }
0364 ... 
0365 ...         if (preg_match("/[a-z]/", $szPwd) && preg_match("/[A-Z]/", $szPwd))
0366 ...         {
0367 ...             $iScore++;
0368 ...         }
0369 ...         if (preg_match("/[0-9]/", $szPwd))
0370 ...         {
0371 ...             $iScore++;
0372 ...         }
0373 ...         if (preg_match("/.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]/", $szPwd))
0374 ...         {
0375 ...             $iScore++;
0376 ...         }
0377 ...     }
0378 ... 
0379 ...     return ( $iScore );
0380 ... }   /* == End of function STR_PasswordStrength() ============================ */
0381 ... 
0382 ... /* ========================================================================== */
0383 ... /** {{*STR_Carve( $szStr,$iLength )=
0384 ... 
0385 ...     Cuts a string into an array of strings
0386 ... 
0387 ...     {*params
0388 ...         $szStr      (string)    The string to process
0389 ...         $iLength    (int)       Maximum length of string chunk.
0390 ...     *}
0391 ... 
0392 ...     {*return
0393 ...         (array)     Array of strings
0394 ...     *}
0395 ... 
0396 ...     {*author  *}
0397 ...     {*cdate 22/04/2014 19:09 *}
0398 ...     {*version 6.0.0006 *}
0399 ... 
0400 ...     {*exec
0401 ...         $szBin  = STR_Binary( "Hello World" );
0402 ...         $aChars = STR_Carve( $szBin,8 );
0403 ... 
0404 ...         echo LSUnitTesting::assert( count( $aChars ) === 11                 ,
0405 ...                                     'ASSERTION SUCCESSFUL: string cut valid',
0406 ...                                     'ASSERTION FAILURE: invalid string cut' ,
0407 ...                                     'GuideAssert' );
0408 ...     *}
0409 ... 
0410 ...     *}}
0411 ...  */
0412 ... /* ========================================================================== */
0413 ... function STR_Carve( $szStr,$iLength = 1 )
0414 ... /*-------------------------------------*/
0415 ... {
0416 ...     return ( str_split( $szStr,$iLength ) );
0417 ... }   /* == End of function STR_Carve() ======================================= */
0418 ... 
0419 ... /* ========================================================================== */
0420 ... /** {{*STR_Chop( $szStr,$cChar )=
0421 ... 
0422 ...     Chops a string and inserts $cChar one character on two
0423 ... 
0424 ...     {*params
0425 ...         $szStr      (string)    The string to process
0426 ...         $cChar      (char)      The character to insert Optional. [c]' '[/c]
0427 ...                                 (blank) by default
0428 ...     *}
0429 ... 
0430 ...     {*return
0431 ...         (string)    $szStr chopped with $cChar
0432 ...     *}
0433 ... 
0434 ...     {*remark
0435 ...         [c]trim()[/c] the string after [c]STR_Chop()[/c] is you need the last default
0436 ...         blank be removed
0437 ...     *}
0438 ... 
0439 ...     {*author
0440 ...         
0441 ...     *}
0442 ... 
0443 ...     {*cdate
0444 ...         12/09/2013 13:12
0445 ...     *}
0446 ... 
0447 ...     {*version
0448 ...         5.5.0000
0449 ...     *}
0450 ... 
0451 ...     {*exec
0452 ...         echo '<p>',STR_Chop( 'Hello World' ),'</p>';
0453 ...     *}
0454 ... 
0455 ...     {*assert
0456 ...         STR_Chop( 'Hello World' ) === 'H e l l o   W o r l d '
0457 ...     *}
0458 ... 
0459 ...     {*assert
0460 ...         STR_Chop( 'Hello World','·' ) === 'H·e·l·l·o· ·W·o·r·l·d·'
0461 ...     *}
0462 ... 
0463 ...     {*assert
0464 ...         STR_Chop( 'Hello World','|' ) === 'H|e|l|l|o| |W|o|r|l|d|'
0465 ...     *}
0466 ... 
0467 ...     *}}
0468 ...  */
0469 ... /* ========================================================================== */
0470 ... function STR_Chop( $szStr,$cChar = ' ' )
0471 ... /*------------------------------------*/
0472 ... {
0473 ...     $szRetVal   = '';
0474 ...     $iLength    = strlen( $szStr );
0475 ... 
0476 ...     for ( $i = 0; $i < $iLength; $i++ )
0477 ...     {
0478 ...         $szRetVal .= $szStr[$i] . $cChar;
0479 ...     }
0480 ... 
0481 ...     return ( $szRetVal );
0482 ... }   /* == End of function STR_Chop() ======================================== */
0483 ... 
0484 ... /* ========================================================================== */
0485 ... /** {{*STR_nl2br( $szString,$szBR )=
0486 ... 
0487 ...     Inserts HTML line breaks before all newlines in a string
0488 ... 
0489 ...     {*params
0490 ...         $szString   (string)    The string whose [c]"\r\n"[/c], [c]"\n\r"[/c],
0491 ...                                 [c]"\n"[/c] or [c]"\r"[/c] must be transformed
0492 ...                                 into line breaks
0493 ...         $szBR       (string)    The mark that represents a line break. Optional.
0494 ...                                 [c]"&lt;br /&gt;"[/c] by default.
0495 ...     *}
0496 ... 
0497 ...     {*return
0498 ...         (string)    $szString with all [c]"\r\n"[/c], [c]"\n\r"[/c], [c]"\n"[/c]
0499 ...                     or [c]"\r"[/c] turned to $szBR
0500 ...     *}
0501 ... 
0502 ...     {*author
0503 ...         
0504 ...     *}
0505 ... 
0506 ...     {*cdate
0507 ...         31/08/2013 12:37
0508 ...     *}
0509 ... 
0510 ...     {*version
0511 ...         5.4.0013
0512 ...     *}
0513 ... 
0514 ...     {*example
0515 ...         $szTooltip = STR_nl2br( trim( STR_Left( STR_Reduce( strip_tags( $szStr ),' ' ),50 ) ),'' );
0516 ...         echo "<p title=\"{$szTooltip}\">blahblahblah</p>";
0517 ...     *}
0518 ... 
0519 ...     {*exec
0520 ...         $szStr =    "<html>\n"                                  .
0521 ...                         "<head>\n\r"                            .
0522 ...                             "<title>My first page</title>\r\n"  .
0523 ...                             "<body>\r"                          .
0524 ...                                 "<h1>My title</h1>\n"           .
0525 ...                                 "<p>My text</p>\n"              .
0526 ...                             "</body>\n"                         .
0527 ...                         "</head>\n"                             .
0528 ...                     "</html>\r";
0529 ...         echo htmlentities( $szStr );
0530 ...         echo '<hr />';
0531 ...         echo wordwrap( htmlentities( $szResult = STR_nl2br( $szStr ) ) );
0532 ...         echo LSUnitTesting::assert( substr_count( $szResult,'<br />' ) === 9                    ,
0533 ...                                     'ASSERTION SUCCESSFUL: line breaks successfully counted'    ,
0534 ...                                     'ASSERTION FAILURE: invalid line breaks count'              ,
0535 ...                                     'GuideAssert' );
0536 ...     *}
0537 ... 
0538 ...     *}}
0539 ...  */
0540 ... /* ========================================================================== */
0541 ... function STR_nl2br( $szString,$szBR = "<br />" )
0542 ... /*--------------------------------------------*/
0543 ... {
0544 ...     //$szGUID     = '{hhh' . guid() . md5( $szGUID ) . 'hhh}';
0545 ...     //$szRetVal   = str_replace( array( "\r\n","\n\r","\n","\r" ),$szGUID,$szString );
0546 ...     //$szRetVal   = str_replace( $szGUID,$szBR,$szRetVal );
0547 ...     $szRetVal   = str_replace( array( "\r\n","\n\r","\n","\r" ),$szBR,$szString );
0548 ... 
0549 ...     return ( $szRetVal );
0550 ... }   /* == End of function STR_nl2br() ======================================= */
0551 ... 
0552 ... /* ========================================================================== */
0553 ... /** {{*STR_Gets( $szStr,$iPos )=
0554 ... 
0555 ...     Gets line from string up to next CR+LF, or CR or LF
0556 ... 
0557 ...     {*params
0558 ...         $szStr  (string)    The source code to extract the next line from
0559 ...         $iPos   (int)       Starting position. Extraction starts at beginning
0560 ...                             of $szStr (0). Parameter passed by reference:
0561 ...                             updated upon return
0562 ...     *}
0563 ... 
0564 ...     {*return
0565 ...         (string)        Next line of text or [c]null[/c] if problem
0566 ...     *}
0567 ... 
0568 ...     {*warning
0569 ...         This function has not passed the approval process yet. Do not
0570 ...         use in a production environment.
0571 ...     *}
0572 ... 
0573 ...     {*exec
0574 ...         $szStr  = "Hello World\nIs All OK?\r\nHave you seen Henry?\n";
0575 ...         $aLines = array();
0576 ...         $i      = 1;
0577 ... 
0578 ...         echo "\n";
0579 ... 
0580 ...         while ( ! is_null( $szLine = STR_Gets( $szStr ) ) )
0581 ...         {
0582 ...             if ( ! is_null( $szLine = "Line  " . $i++ . ": {$szLine}\n" ) );
0583 ...             {
0584 ...                 $aLines[] = $szLine;
0585 ...                 echo "<p>",$szLine,"<p>";
0586 ...             }
0587 ...         }
0588 ... 
0589 ...         echo "<p>",STR_binary( $aLines[3] ),"<p>";
0590 ... 
0591 ...         echo LSUnitTesting::assert( count( $aLines ) === 3                      ,
0592 ...                                     'ASSERTION SUCCESSFUL: correct line count'  ,
0593 ...                                     'ASSERTION FAILURE: incorrect line count'   ,
0594 ...                                     'GuideAssert' );
0595 ...     *}
0596 ... 
0597 ...     *}}
0598 ...  */
0599 ... /* ========================================================================== */
0600 ... function STR_Gets( $szStr )
0601 ... /*-----------------------*/
0602 ... {
0603 ...     static $iLastLine = null;
0604 ...     static $aLines    = null;
0605 ...     static $iCount    = null;
0606 ... 
0607 ...     if ( is_null( $iLastLine ) )
0608 ...     {
0609 ...         $iLastLine = 0;
0610 ...         $aLines    = STR_aLines( $szStr );
0611 ...         $iCount    = count( $aLines );
0612 ...     }
0613 ...     else
0614 ...     {
0615 ...         $iLastLine++;
0616 ...     }
0617 ... 
0618 ...     if ( $iLastLine >= 0 && ( $iLastLine < $iCount ) )
0619 ...     {
0620 ...         //return ( STR_Eliminate( $aLines[$iLastLine],chr(13) . chr(10) ) );
0621 ...         return ( str_replace( array( "\r","\n" ),'',$aLines[$iLastLine] ) );
0622 ...     }   /* if ( $iLastLine >= 0 && ( $iLastLine < $iCount ) ) */
0623 ...     else   /* Else of ... if ( $iLastLine >= 0 && ( $iLastLine < $iCount ) ) */
0624 ...     {
0625 ...         return ( null );
0626 ...     }   /* End of ... Else of ... if ( $iLastLine >= 0 && ( $iLastLine < $iCount ) ) */
0627 ... 
0628 ... }   /* == End of function STR_Gets() ======================================== */
0629 ... 
0630 ... /* ========================================================================== */
0631 ... /** {{*STR_Eliminate( $szStr,$szCharList )=
0632 ... 
0633 ...     Eliminates all characters of $szCharList from $szStr
0634 ... 
0635 ...     {*params
0636 ...         $szStr      (string)    The string to process
0637 ...         $szCharList (string)    The list of characters to get rid of
0638 ...     *}
0639 ... 
0640 ...     {*return
0641 ...         (string)        $szStr amputated from all chars found in $szCharList
0642 ...     *}
0643 ... 
0644 ...     {*exec
0645 ...         $szStr   = "Hello World\nIs All OK?\r\nHave you seen Henry?";
0646 ...         $iLength = strlen( $szStr);
0647 ...         echo '<p>Length was: '                          ,
0648 ...                  $iLength                               ,
0649 ...                  '<br />'                               ,
0650 ...                  $szStr = STR_Eliminate( $szStr,"\r\n" ),
0651 ...                  '<br />New length is: '                ,
0652 ...                  $iLength = strlen( $szStr )            ,
0653 ...                  "</p>\n";
0654 ...         echo LSUnitTesting::assert( $iLength === 41                                     ,
0655 ...                                     'ASSERTION SUCCESSFUL: correct length for $szStr'   ,
0656 ...                                     'ASSERTION FAILURE: incorrect length for $szStr'    ,
0657 ...                                     'GuideAssert' );
0658 ...     *}
0659 ... 
0660 ...     {*seealso
0661 ...         STR_Keep()
0662 ...     *}
0663 ... 
0664 ...     {*alias
0665 ...         STR_Avoid()
0666 ...     *}
0667 ...     *}}
0668 ...  */
0669 ... /* ========================================================================== */
0670 ... function STR_Eliminate( $szStr,$szCharList )
0671 ... /*----------------------------------------*/
0672 ... {
0673 ...     $iPos       = 0;                                                /* Current position */
0674 ...     $iLength    = strlen( $szStr );                                 /* Length fo string to process */
0675 ...     $szRetVal   = '';                                               /* Return value of the function */
0676 ... 
0677 ...     while ( $iPos < $iLength )                                      /* While we haven't treated the whole source code */
0678 ...     {
0679 ...         if ( STR_Pos( $szCharList,($c = $szStr[$iPos++]) ) == -1 )  /* Character we just read */
0680 ...         {
0681 ...             $szRetVal .= $c;                                        /* Add it to the return value */
0682 ...         }
0683 ...     }   /* while ( $iPos < $iLength ) */
0684 ... 
0685 ...     return ( $szRetVal );                                           /* Return result to caller */
0686 ... }   /* == End of function STR_Eliminate() =================================== */
0687 ... function STR_Avoid( $szStr,$szCharList ) { return ( STR_Eliminate( $szStr,$szCharList ) ); }
0688 ... 
0689 ... /* ========================================================================== */
0690 ... /** {{*STR_DetectLanguage( $szText[,$szDefault[,$iCount]] )=
0691 ... 
0692 ...     Detects language of a text automatically
0693 ... 
0694 ...     {*params
0695 ...         $szText     (string)    The text to process. By reference. Identical upon
0696 ...                                 exit
0697 ...         $szDefault  (string)    Default language
0698 ...         $iCount     (int)       Number of words to use to detect the language.
0699 ...                                 Optional : 50 by default;
0700 ...     *}
0701 ... 
0702 ...     {*return
0703 ...         (string)        $szStr amputated from all chars found in $szCharList
0704 ...     *}
0705 ... 
0706 ...     {*warning
0707 ...         This function is experimental and works only for the following
0708 ...         languages: catalan, czech, german, english, spanish, french, italian,
0709 ...         dutch, portuguese
0710 ...     *}
0711 ... 
0712 ...     {*exec
0713 ...         $szStr = "Ce texte est un texte écrit en français durant l'été";
0714 ...         echo LSUnitTesting::assert( STR_DetectLanguage( $szStr,'fr' ) == 'fr'       ,
0715 ...                                     'ASSERTION SUCCESSFUL: Language detection OK'   ,
0716 ...                                     'ASSERTION FAILURE: Language detection failed'  ,
0717 ...                                     'GuideAssert' );
0718 ...     *}
0719 ... 
0720 ...     *}}
0721 ...  */
0722 ... /* ====================================================================== */
0723 ... function STR_DetectLanguage( &$szText,$szDefault = '?',$iCount = 50 )
0724 ... /*-----------------------------------------------------------------*/
0725 ... {
0726 ...     //https://en.m.wikipedia.org/wiki/Most_common_words_in_English
0727 ...     //http://www.101languages.net/dutch/most-common-dutch-words/
0728 ...     //http://wortschatz.uni-leipzig.de/Papers/top100de.txt
0729 ...     //http://netia59a.ac-lille.fr/va.anzin/IMG/pdf/mots_les_plus_frequents.pdf
0730 ...     //https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/
0731 ...     //https://fr.wiktionary.org/wiki/Wiktionnaire:Listes_de_fr%C3%A9quence
0732 ... 
0733 ...     $aLanguages = array( 'ca','cs','de','en','es','fr','it','nl','pt' );
0734 ... 
0735 ...     {   /* Catalan - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Catalan/1-2000 */
0736 ...         include( 'catalan-words.php' );
0737 ...     }
0738 ... 
0739 ...     {   /* Czech - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Czech_wordlist */
0740 ...         include( 'czech-words.php' );
0741 ...     }
0742 ... 
0743 ...     {   /* German - 200 - https://fr.wiktionary.org/wiki/Wiktionnaire:Listes_de_fr%C3%A9quence/wortschatz-de-1-2000 */
0744 ...         include( 'german-words.php' );
0745 ...     }
0746 ... 
0747 ...     {   /* English - 200 - https://en.m.wikipedia.org/wiki/Most_common_words_in_English */
0748 ...         include( 'english-words.php' );
0749 ...     }
0750 ... 
0751 ...     {   /* Spanish - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Spanish1000 */
0752 ...         include( 'spanish-words.php' );
0753 ...     }
0754 ... 
0755 ...     {   /* French - 200 - https://fr.wiktionary.org/wiki/Wiktionnaire:Listes_de_fr%C3%A9quence/wortschatz-fr-1-2000 */
0756 ...         include( 'french-words.php' );
0757 ...     }
0758 ... 
0759 ...     {   /* Italian - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Italian1000 */
0760 ...         include( 'italian-words.php' );
0761 ...     }
0762 ... 
0763 ...     {   /* Dutch - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Dutch_wordlist */
0764 ...         include( 'dutch-words.php' );
0765 ...     }
0766 ... 
0767 ...     {   /* Portuguese - 200 - https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Portuguese_wordlist */
0768 ...         include( 'portuguese-words.php' );
0769 ...     }
0770 ... 
0771 ... 
0772 ...     // count the occurrences of the most frequent words
0773 ...     foreach ( $aLanguages as $szLang )
0774 ...     {
0775 ...         $counter[$szLang] = 0;
0776 ...     }
0777 ... 
0778 ...     //$iLimit = count( $aWords['es'] );
0779 ...     $iLimit = min( $iCount,count( $aWords['ca'] ) );
0780 ... 
0781 ...     for ( $i = 0; $i < $iLimit; $i++ )
0782 ...     {
0783 ...         foreach ( $aLanguages as $szLang )
0784 ...         {
0785 ...             $counter[$szLang] += substr_count( $szText,' ' . $aWords[$szLang][$i] . ' ' );
0786 ...         }
0787 ...     }
0788 ... 
0789 ...     //foreach ( $aLanguages as $szLang )
0790 ...     //{
0791 ...     //    var_dump( $counter[$szLang] );
0792 ...     //}
0793 ... 
0794 ...     // get max counter value
0795 ...     // from http://stackoverflow.com/a/1461363
0796 ...     $iMaxMatches = max( $counter );
0797 ... 
0798 ...     //var_dump( $iMaxMatches );
0799 ... 
0800 ...     $aWinningLanguages = array_keys( $counter,$iMaxMatches );
0801 ...     //var_dump( $aWinningLanguages );
0802 ... 
0803 ...     if ( count( $aWinningLanguages ) > 0 )
0804 ...     {
0805 ...         //var_dump( $aWinningLanguages );
0806 ...         return( $szWinner = $aWinningLanguages[0] );
0807 ...         //$second = 0;
0808 ...         //echo "<p>On a un gagnant et c'est {$szWinner}</p>";
0809 ...         //
0810 ...         //// get runner-up (second place)
0811 ...         //foreach ( $aLanguages as $szLang )
0812 ...         //{
0813 ...         //    if ( $szLang <> $szWinner )
0814 ...         //    {
0815 ...         //        if ( $counter[$szLang] > $second )
0816 ...         //        {
0817 ...         //            $second = $counter[$szLang];
0818 ...         //        }
0819 ...         //    }
0820 ...         //}
0821 ...         //
0822 ...         //echo "<p>Le second est {$second}</p>";
0823 ...         //
0824 ...         //
0825 ...         //
0826 ...         //// apply arbitrary threshold of 10%
0827 ...         //if ( ( $second / $max ) < 0.1 )
0828 ...         //{
0829 ...         //    return ( $szWinner );
0830 ...         //}
0831 ...     }
0832 ... 
0833 ...     return ( $szDefault );
0834 ... }   /* == End of function STR_DetectLanguage() ============================== */
0835 ... 
0836 ... /*
0837 ... https://www.octopuce.fr/soundex-en-francais-algorithme-dextraction-de-racine-phonetique-pour-moteur-de-recherche/
0838 ... http://www.roudoudou.com/phonetic.php
0839 ... http://sqlpro.developpez.com/cours/soundex/
0840 ... 
0841 ... Bonnes ressources linguistiques:
0842 ... http://www.lexique.org/listes/liste_syllabes.php
0843 ... 
0844 ... */
0845 ... 
0846 ... /* This code implements the following algorithm:
0847 ... http://sqlpro.developpez.com/cours/soundex/#L4
0848 ... 
0849 ... 1) �liminer les blancs à droite et à gauche du nom
0850 ... 2) Convertir le nom en majuscule
0851 ... 3) Convertir les lettres accentuées et le c cédille en lettres non accentuées
0852 ... 4) Eliminer les blancs et les tirets
0853 ... 5) Remplacer les groupes de lettres suivantes par leur correspondance (en conservant l'ordre du tableau) :
0854 ...  - GUI ... KI
0855 ...  - GUE ... KE
0856 ...  - GA  ... KA
0857 ...  - GO  ... KO
0858 ...  - GU  ... K
0859 ...  - CA  ... KA
0860 ...  - CO  ... KO
0861 ...  - CU  ... KU
0862 ...  - Q   ... K
0863 ...  - CC  ... K
0864 ...  - CK  ... K
0865 ... 
0866 ... 6) Remplacer toutes les voyelles sauf le Y par A exceptée la premiÚre lettre
0867 ... 7) Remplacer les préfixes suivants par leur correspondance :
0868 ... 
0869 ...  - MAC ... MCC
0870 ...  - ASA ... AZA  (ASAmian)
0871 ...  - KN  ... NN   (KNight)
0872 ...  - PF  ... FF   (PFeiffer)
0873 ...  - SCH ... SSS  (SCHindler)
0874 ...  - PH  ... FF   (PHilippe)
0875 ... 
0876 ... 8) Supprimer les H sauf s'ils sont précédés par C ou S
0877 ... 9) Supprimer les Y sauf s'il est précédé d'un A
0878 ... 10) Supprimer les terminaisons suivantes A, T, D et S
0879 ... 11) Enlever tous les A sauf le A de tête s'il y en a un
0880 ... 12) Enlever toutes les sous chaînes de lettre répétitives
0881 ... 13) Conserver les 4 premiers caractÚres du mot et si besoin le compléter avec des blancs pour obtenir 4 caractÚres
0882 ... 
0883 ... NOTE: la lettre X n'est pas vraiment bien gérée.
0884 ... 
0885 ... Il faudrait améliorer l'algorithme pour que Bruxelles soit traité comme
0886 ... Brussel ou Brussels mais que doux, eux, ... soient traités différemment
0887 ... 
0888 ... */
0889 ... 
0890 ... function STR_soundexFr( $szStr,$bDebug = false )
0891 ... /*--------------------------------------------*/
0892 ... {
0893 ...     if ( ! STR_Empty( $szStr ) )
0894 ...     {
0895 ...         if ( $bDebug )
0896 ...         {
0897 ...             echo "<p>START OF ALGORITHM</p>\n";
0898 ... 
0899 ...             echo "<pre>\n";
0900 ...             echo $szStr;
0901 ...             echo "</pre>\n";
0902 ...         }
0903 ... 
0904 ...         $szStr  = strtoupper( STR_Eliminate( mb_convert_encoding( STR_stripAccents( trim( $szStr ) ),'Windows-1252' ),'- ' ) );
0905 ... 
0906 ...         if ( $bDebug )
0907 ...         {
0908 ...             echo "<p>START SEQUENCE</p>\n";
0909 ...             echo "<p>1) �liminer les blancs à droite et à gauche du nom</p>\n";
0910 ...             echo "<p>2) Convertir le nom en majuscule</p>\n";
0911 ...             echo "<p>3) Convertir les lettres accentuées et le c cédille en lettres non accentuées</p>\n";
0912 ...             echo "<p>4) Eliminer les blancs et les tirets</p>\n";
0913 ... 
0914 ...             echo "<pre>\n";
0915 ...             echo $szStr;
0916 ...             echo "</pre>\n";
0917 ...         }
0918 ... 
0919 ...         $szStr  = str_replace( array( "GUI",     /* 01 */
0920 ...                                       "GUE",     /* 02 */
0921 ...                                       "GA" ,     /* 03 */
0922 ...                                       "GO" ,     /* 04 */
0923 ...                                       "GU" ,     /* 05 */
0924 ...                                       "CA" ,     /* 06 */
0925 ...                                       "CO" ,     /* 07 */
0926 ...                                       "CU" ,     /* 08 */
0927 ...                                       "Q"  ,     /* 09 */
0928 ...                                       "CC" ,     /* 10 */
0929 ...                                       "CK" ),    /* 11 */
0930 ...                                array( "KI" ,     /* 01 */
0931 ...                                       "KE" ,     /* 02 */
0932 ...                                       "KA" ,     /* 03 */
0933 ...                                       "KO" ,     /* 04 */
0934 ...                                       "K"  ,     /* 05 */
0935 ...                                       "KA" ,     /* 06 */
0936 ...                                       "KO" ,     /* 07 */
0937 ...                                       "KU" ,     /* 08 */
0938 ...                                       "K"  ,     /* 09 */
0939 ...                                       "K"  ,     /* 10 */
0940 ...                                       "K" ),     /* 11 */
0941 ...                                 $szStr );
0942 ...         if ( $bDebug )
0943 ...         {
0944 ...             echo "<p>START SEQUENCE</p>\n";
0945 ...             echo "<p>5) Remplacer les groupes de lettres suivantes par leur correspondance (en conservant l'ordre du tableau)</p>\n";
0946 ...             echo "<p> - GUI ... KI</p>\n";
0947 ...             echo "<p> - GUE ... KE</p>\n";
0948 ...             echo "<p> - GA  ... KA</p>\n";
0949 ...             echo "<p> - GO  ... KO</p>\n";
0950 ...             echo "<p> - GU  ... K</p>\n";
0951 ...             echo "<p> - CA  ... KA</p>\n";
0952 ...             echo "<p> - CO  ... KO</p>\n";
0953 ...             echo "<p> - CU  ... KU</p>\n";
0954 ...             echo "<p> - Q   ... K</p>\n";
0955 ...             echo "<p> - CC  ... K</p>\n";
0956 ...             echo "<p> - CK  ... K</p>\n";
0957 ... 
0958 ...             echo "<pre>\n";
0959 ...             echo $szStr;
0960 ...             echo "</pre>\n";
0961 ...         }
0962 ... 
0963 ...         $szStr  = $szStr[0] . str_replace( array( 'E','I','O','U' ),'A',substr( $szStr,1 ) );
0964 ...         if ( $bDebug )
0965 ...         {
0966 ...             echo "<p>START SEQUENCE</p>\n";
0967 ...             echo "<p>6) Remplacer toutes les voyelles sauf le Y par A exceptée la premiÚre lettre</p>\n";
0968 ... 
0969 ...             echo "<pre>\n";
0970 ...             echo $szStr;
0971 ...             echo "</pre>\n";
0972 ...         }
0973 ... 
0974 ...         // All replaced by 1 call:
0975 ...         //$szStr  = preg_replace( '/\AMAC/sim'      ,'MCC',$szStr );
0976 ...         //$szStr  = preg_replace( '/\ASCH/sim'      ,'SSS',$szStr );
0977 ...         //$szStr  = preg_replace( '/\AASA/sim'      ,'AZA',$szStr );
0978 ...         //$szStr  = preg_replace( '/\AKN/sim'       ,'NN' ,$szStr );
0979 ...         //$szStr  = preg_replace( '/\A(PH|PF)/sim'  ,'FF' ,$szStr );
0980 ... 
0981 ...         $szStr  = preg_replace( array( '/\AMAC/sim'      ,
0982 ...                                        '/\ASCH/sim'      ,
0983 ...                                        '/\AASA/sim'      ,
0984 ...                                        '/\AKN/sim'       ,
0985 ...                                        '/\A(PH|PF)/sim' ),
0986 ...                                 array( 'MCC'             ,
0987 ...                                        'SSS'             ,
0988 ...                                        'AZA'             ,
0989 ...                                        'NN'              ,
0990 ...                                        'FF' ),
0991 ...                                 $szStr );
0992 ...         if ( $bDebug )
0993 ...         {
0994 ...             echo "<p>START SEQUENCE</p>\n";
0995 ...             echo "<p>7) Remplacer les préfixes suivants par leur correspondance :</p>\n";
0996 ...             echo "<p> - MAC ... MCC</p>\n";
0997 ...             echo "<p> - ASA ... AZA  (ASAmian)</p>\n";
0998 ...             echo "<p> - KN  ... NN   (KNight)</p>\n";
0999 ...             echo "<p> - PF  ... FF   (PFeiffer)</p>\n";
1000 ...             echo "<p> - SCH ... SSS  (SCHindler)</p>\n";
1001 ...             echo "<p> - PH  ... FF   (PHilippe)</p>\n";
1002 ... 
1003 ...             echo "<pre>\n";
1004 ...             echo $szStr;
1005 ...             echo "</pre>\n";
1006 ...         }
1007 ... 
1008 ...         // Replace all H with '', except if preceded by S or C
1009 ...         $szStr  = preg_replace( '/(?<!(S|C))H/si','',$szStr );
1010 ...         if ( $bDebug )
1011 ...         {
1012 ...             echo "<p>START SEQUENCE</p>\n";
1013 ...             echo "<p>8) Supprimer les H sauf s'ils sont précédés par S ou C</p>\n";
1014 ... 
1015 ...             echo "<pre>\n";
1016 ...             echo $szStr;
1017 ...             echo "</pre>\n";
1018 ...         }
1019 ... 
1020 ...         // Replace all Y with '', except if preceded by A
1021 ...         $szStr  = preg_replace( '/(?<!(A))Y/si','',$szStr );
1022 ...         if ( $bDebug )
1023 ...         {
1024 ...             echo "<p>START SEQUENCE</p>\n";
1025 ...             echo "<p>9) Supprimer les Y sauf s'il est précédé d'un A</p>\n";
1026 ... 
1027 ...             echo "<pre>\n";
1028 ...             echo $szStr;
1029 ...             echo "</pre>\n";
1030 ...         }
1031 ... 
1032 ...         // Remove A D T S at the end of the string
1033 ...         $szStr  = preg_replace( '/(A|D|T|S)\z/si','',$szStr );
1034 ...         if ( $bDebug )
1035 ...         {
1036 ...             echo "<p>START SEQUENCE</p>\n";
1037 ...             echo "<p>10) Supprimer les terminaisons suivantes A, T, D et S</p>\n";
1038 ... 
1039 ...             echo "<pre>\n";
1040 ...             echo $szStr;
1041 ...             echo "</pre>\n";
1042 ...         }
1043 ... 
1044 ...         // Remove all A except at the start of the string
1045 ...         $szStr  = preg_replace( '/(?!^)A/si','',$szStr );
1046 ...         if ( $bDebug )
1047 ...         {
1048 ...             echo "<p>START SEQUENCE</p>\n";
1049 ...             echo "<p>11) Enlever tous les A sauf le A de tête s'il y en a un</p>\n";
1050 ... 
1051 ...             echo "<pre>\n";
1052 ...             echo $szStr;
1053 ...             echo "</pre>\n";
1054 ...         }
1055 ... 
1056 ...         $szStr  = STR_Reduce2( $szStr );
1057 ...         if ( $bDebug )
1058 ...         {
1059 ...             echo "<p>START SEQUENCE</p>\n";
1060 ...             echo "<p>12) Enlever toutes les sous chaînes de lettres répétitives</p>\n";
1061 ... 
1062 ...             echo "<pre>\n";
1063 ...             echo $szStr;
1064 ...             echo "</pre>\n";
1065 ...         }
1066 ... 
1067 ...         $szStr  = str_pad( $szStr,4 );
1068 ...         if ( $bDebug )
1069 ...         {
1070 ...             echo "<p>START SEQUENCE</p>\n";
1071 ...             echo "<p>13) Conserver les 4 premiers caractÚres du mot et si besoin le compléter avec des blancs pour obtenir 4 caractÚres</p>\n";
1072 ... 
1073 ...             echo "<pre>\n";
1074 ...             echo $szStr;
1075 ...             echo "</pre>\n";
1076 ...         }
1077 ...     }
1078 ... 
1079 ...     return ( $szStr );
1080 ... }
1081 ... 
1082 ... /*
1083 ...     AUTRE ALGORITHME ... BEAUCOUP PLUS LONG ... MAIS QUI PROPOSE UNE REPONSE TRES
1084 ...     INTERESSANTE!!! (voir http://www.roudoudou.com/phonetic.php#phonetic)
1085 ... 
1086 ... 	SOUNDEX FR
1087 ... 
1088 ... 	�douard BERG� © 12.2007 v1.2
1089 ... 
1090 ... ---------------------------------------------------------------------------------------------------------
1091 ... Cet algorithme et son application en PHP sont tous deux distribués sous la licence
1092 ... 
1093 ...         Creative Commons Paternité - Pas d'Utilisation Commerciale 2.0
1094 ...             http://creativecommons.org/licenses/by-nc/2.0/fr/
1095 ... 
1096 ... Vous êtes libres :
1097 ...     - de reproduire, distribuer et communiquer cette création au public
1098 ...     - de modifier cette création
1099 ... 
1100 ... Selon les conditions suivantes :
1101 ...     - Paternité. Vous devez citer le nom de l'auteur original de la maniÚre indiquée
1102 ...         par l'auteur de l'oeuvre ou le titulaire des droits qui vous confÚre cette
1103 ...         autorisation (mais pas d'une maniÚre qui suggérerait qu'ils vous soutiennent
1104 ...         ou approuvent votre utilisation de l'oeuvre).
1105 ...         Demande de l'auteur: Citer "Ã?douard BERGÃ?" et/ou " http://www.roudoudou.com"
1106 ...     - Pas d'Utilisation Commerciale. Vous n'avez pas le droit d'utiliser cette
1107 ...         création à des fins commerciales sauf autorisation de l'auteur.
1108 ... ---------------------------------------------------------------------------------------------------------
1109 ... 
1110 ... Pourquoi un nouveau Soundex? Il en existe déjà beaucoup de variantes non? Oui mais...
1111 ... 
1112 ... - Ils généralisent trop les sons, provocants beaucoup de faux positifs.
1113 ... - Leur conversion phonétique est limitée alors que le français est complexe, résultant beaucoup de manqués.
1114 ... 
1115 ... L'objectif est donc clair. Je veux...
1116 ... 
1117 ... - Moins de faux positifs.
1118 ... - Plus de réussite.
1119 ... - De plus, je trouve pratique d'avoir une conversion qui reste "lisible".
1120 ... - Une certaine correction des erreurs orthographiques les plus courantes.
1121 ... 
1122 ... Commençant mes développements avec 200 mots de référence, relire cette liste à chaque fois était
1123 ... ridiculement improductif et source d'erreurs. Je suis alors passé à la vitesse supérieure en me
1124 ... 
1125 ... constituant un corpus de test de 7.000 mots (choisis en "feuilletant" un dictionnaire), ainsi
1126 ... qu'une page de test pour automatiser les vérifications et la détection d'éventuelles régressions.
1127 ... 
1128 ... Pour terminer la validation de mon algorithme, j'ai téléchargé une version française du
1129 ... dictionnaire myspell pour l'ajouter à ma page de test. Cette ultime vérification me permit
1130 ... de corriger quelques imperfections. Au final, cet algorithme a été testé avec plus de 70.000 mots.
1131 ... 
1132 ... Attention, il n'est pas parfait!  Mais j'ai enfin eu ce que je voulais, avec trÚs peu de concessions,
1133 ... à savoir un algorithme qui se comporte bien avec des mots français. L'occasion pour moi de remercier
1134 ... quelques personnes:
1135 ... 
1136 ... - Frédéric Brouard pour son article sur les soundex.
1137 ... http://sqlpro.developpez.com/cours/soundex/
1138 ... 
1139 ... - Florent Bruneau de qui j'ai repris quelques morceaux de code. Lui même inspiré par Frédéric Brouard.
1140 ... http://blog.mymind.fr/post/2007/03/15/Soundex-Francais
1141 ... 
1142 ... - Christophe Pythoud et Vazkor (Jean-Claude M.) pour leur immense travail sur le dictionnaire myspell.
1143 ... http://perso.latribu.com/rocky2/index.html (Le chien n'est pas méchant)
1144 ... 
1145 ... 
1146 ... Une nouvelle version?
1147 ... 
1148 ... Je n'ai pas encore d'axe de travail. Soit je me sers de mon corpus de test pour compacter le code produit
1149 ... tout en gardant l'unicité de sens, soit j'utiliserai un dictionnaire. Mais on n'en est pas encore là.
1150 ... 
1151 ... Ã?douard BERGÃ?
1152 ... */
1153 ... 
1154 ... function phonetique($sIn)
1155 ... {
1156 ... $accents = array('Ã?' => 'E', 'Ã?' => 'E', 'Ã?' => 'E', 'Ã?' => 'E','Ã?' => 'A', 'Ã?' => 'A', 'Ã?' => 'A', 'Ã?' => 'A',
1157 ... 				'Ã?' => 'A', 'Ã?' => 'A', 'Ã?' => 'E','Ã?' => 'I', 'Ã?' => 'I', 'Ã?' => 'I', 'Ã?' => 'I',
1158 ... 				'Ã?' => 'O', 'Ã?' => 'O', 'Ã?' => 'O', 'Ã?' => 'O', 'Ã?' => 'O', 'Ã?' => 'O', 'Å?' => 'OEU',
1159 ... 				'�' => 'U', '�' => 'U', '�' => 'U', '�' => 'U','�' => 'N', '�' => 'S', '¿' => 'E');
1160 ... 
1161 ... $min2maj = array('é' => '�', 'Ú' => '�', 'ë' => '�', 'ê' => '�','á' => '�', 'â' => '�', 'à' => '�', '�' => 'A',
1162 ... 				'�' => 'A', 'å' => '�', 'ã' => '�', 'Ê' => '�',	'ï' => '�', 'î' => '�', 'ì' => '�', 'í' => '�',
1163 ... 				'Ã?' => 'Ã?', 'ö' => 'Ã?', 'ò' => 'Ã?', 'ó' => 'Ã?','õ' => 'Ã?', 'Ã?' => 'Ã?', 'Å?' => 'Å?',
1164 ... 				'ú' => '�', 'ù' => '�', 'û' => '�', 'Ì' => '�','ç' => '�', 'ñ' => '�', '�' => 'S');
1165 ... 
1166 ... 
1167 ... //$sIn = utf8_decode($sIn);						// Selon votre implémentation, vous aurez besoin de décoder ce qui arrive pour les caractÚres spéciaux
1168 ... $sIn = strtr( $sIn, $min2maj); 					// minuscules accentuées ou composées en majuscules simples
1169 ... $sIn = strtr( $sIn, $accents); 					// majuscules accentuées ou composées en majuscules simples
1170 ... $sIn = strtoupper( $sIn );     					// on passe tout le reste en majuscules
1171 ... $sIn = preg_replace( '`[^A-Z]`', '', $sIn ); 	// on garde uniquement les lettres de A à Z
1172 ... 
1173 ... $sBack=$sIn;									// on sauve le code (utilisé pour les mots trÚs courts)
1174 ... 
1175 ... $sIn = preg_replace( '`O[O]+`', 'OU', $sIn ); 	// pré traitement OO... -> OU
1176 ... $sIn = preg_replace( '`SAOU`', 'SOU', $sIn ); 	// pré traitement SAOU -> SOU
1177 ... $sIn = preg_replace( '`OES`', 'OS', $sIn ); 	// pré traitement OES -> OS
1178 ... $sIn = preg_replace( '`CCH`', 'K', $sIn ); 		// pré traitement CCH -> K
1179 ... $sIn = preg_replace( '`CC([IYE])`', 'KS$1', $sIn ); // CCI CCY CCE
1180 ... $sIn = preg_replace( '`(.)\1`', '$1', $sIn ); 	// supression des répétitions
1181 ... 
1182 ... // quelques cas particuliers
1183 ... if ($sIn=="CD") return($sIn);
1184 ... if ($sIn=="BD") return($sIn);
1185 ... if ($sIn=="BV") return($sIn);
1186 ... if ($sIn=="TABAC") return("TABA");
1187 ... if ($sIn=="FEU") return("FE");
1188 ... if ($sIn=="FE") return($sIn);
1189 ... if ($sIn=="FER") return($sIn);
1190 ... if ($sIn=="FIEF") return($sIn);
1191 ... if ($sIn=="FJORD") return($sIn);
1192 ... if ($sIn=="GOAL") return("GOL");
1193 ... if ($sIn=="FLEAU") return("FLEO");
1194 ... if ($sIn=="HIER") return("IER");
1195 ... if ($sIn=="HEU") return("E");
1196 ... if ($sIn=="HE") return("E");
1197 ... if ($sIn=="OS") return($sIn);
1198 ... if ($sIn=="RIZ") return("RI");
1199 ... if ($sIn=="RAZ") return("RA");
1200 ... 
1201 ... // pré-traitements
1202 ... $sIn = preg_replace( '`OIN[GT]$`', 'OIN', $sIn );									// terminaisons OING -> OIN
1203 ... $sIn = preg_replace( '`E[RS]$`', 'E', $sIn ); 										// supression des terminaisons infinitifs et participes pluriels
1204 ... $sIn = preg_replace( '`(C|CH)OEU`', 'KE', $sIn ); 									// pré traitement OEU -> EU
1205 ... $sIn = preg_replace( '`MOEU`', 'ME', $sIn ); 										// pré traitement OEU -> EU
1206 ... $sIn = preg_replace( '`OE([UI]+)([BCDFGHJKLMNPQRSTVWXZ])`', 'E$1$2', $sIn ); 		// pré traitement OEU OEI -> E
1207 ... $sIn = preg_replace( '`^GEN[TS]$`', 'JAN', $sIn );									// pré traitement GEN -> JAN
1208 ... $sIn = preg_replace( '`CUEI`', 'KEI', $sIn ); 										// pré traitement accueil
1209 ... $sIn = preg_replace( '`([^AEIOUYC])AE([BCDFGHJKLMNPQRSTVWXZ])`', '$1E$2', $sIn ); 	// pré traitement AE -> E
1210 ... $sIn = preg_replace( '`AE([QS])`', 'E$1', $sIn ); 									// pré traitement AE -> E
1211 ... $sIn = preg_replace( '`AIE([BCDFGJKLMNPQRSTVWXZ])`', 'AI$1', $sIn );				// pré-traitement AIE(consonne) -> AI
1212 ... $sIn = preg_replace( '`ANIEM`', 'ANIM', $sIn ); 									// pré traitement NIEM -> NIM
1213 ... $sIn = preg_replace( '`(DRA|TRO|IRO)P$`', '$1', $sIn ); 							// P terminal muet
1214 ... $sIn = preg_replace( '`(LOM)B$`', '$1', $sIn ); 									// B terminal muet
1215 ... $sIn = preg_replace( '`(RON|POR)C$`', '$1', $sIn ); 								// C terminal muet
1216 ... $sIn = preg_replace( '`PECT$`', 'PET', $sIn ); 										// C terminal muet
1217 ... $sIn = preg_replace( '`ECUL$`', 'CU', $sIn ); 										// L terminal muet
1218 ... $sIn = preg_replace( '`(CHA|CA|E)M(P|PS)$`', '$1N', $sIn ); 		 				// P ou PS terminal muet
1219 ... $sIn = preg_replace( '`(TAN|RAN)G$`', '$1', $sIn ); 			 					// G terminal muet
1220 ... 
1221 ... 
1222 ... // sons YEUX
1223 ... $sIn = preg_replace( '`([^VO])ILAG`', '$1IAJ', $sIn );
1224 ... $sIn = preg_replace( '`([^TRH])UIL(AR|E)(.+)`', '$1UI$2$3', $sIn );
1225 ... $sIn = preg_replace( '`([G])UIL([AEO])`', '$1UI$2', $sIn );
1226 ... $sIn = preg_replace( '`([NSPM])AIL([AEO])`', '$1AI$2', $sIn );
1227 ... $convMIn  = array("DILAI","DILON","DILER","DILEM","RILON","TAILE","GAILET","AILAI","AILAR",
1228 ... "OUILA","EILAI","EILAR","EILER","EILEM","REILET","EILET","AILOL" );
1229 ... $convMOut = array( "DIAI", "DION","DIER", "DIEM", "RION", "TAIE", "GAIET", "AIAI", "AIAR",
1230 ... "OUIA", "AIAI", "AIAR", "AIER", "AIEM",  "RAIET", "EIET", "AIOL" );
1231 ... $sIn = str_replace( $convMIn, $convMOut, $sIn );
1232 ... $sIn = preg_replace( '`([^AEIOUY])(SC|S)IEM([EA])`', '$1$2IAM$3', $sIn ); 	// IEM -> IAM
1233 ... $sIn = preg_replace( '`^(SC|S)IEM([EA])`', '$1IAM$2', $sIn ); 				// IEM -> IAM
1234 ... 
1235 ... // MP MB -> NP NB
1236 ... $convMIn  = array( 'OMB', 'AMB', 'OMP', 'AMP', 'IMB', 'EMP','GEMB','EMB', 'UMBL','CIEN');
1237 ... $convMOut = array( 'ONB', 'ANB', 'ONP', 'ANP', 'INB', 'ANP','JANB','ANB', 'INBL','SIAN');
1238 ... $sIn = str_replace( $convMIn, $convMOut, $sIn );
1239 ... 
1240 ... // Sons en K
1241 ... $sIn = preg_replace( '`^ECHO$`', 'EKO', $sIn ); 	// cas particulier écho
1242 ... $sIn = preg_replace( '`^ECEUR`', 'EKEUR', $sIn ); 	// cas particulier écÅ?uré
1243 ... // Choléra ChÅ?ur mais pas chocolat!
1244 ... $sIn = preg_replace( '`^CH(OG+|OL+|OR+|EU+|ARIS|M+|IRO|ONDR)`', 'K$1', $sIn ); 				//En début de mot
1245 ... $sIn = preg_replace( '`(YN|RI)CH(OG+|OL+|OC+|OP+|OM+|ARIS|M+|IRO|ONDR)`', '$1K$2', $sIn ); 	//Ou devant une consonne
1246 ... $sIn = preg_replace( '`CHS`', 'CH', $sIn );
1247 ... $sIn = preg_replace( '`CH(AIQ)`', 'K$1', $sIn );
1248 ... $sIn = preg_replace( '`^ECHO([^UIPY])`', 'EKO$1', $sIn );
1249 ... $sIn = preg_replace( '`ISCH(I|E)`', 'ISK$1', $sIn );
1250 ... $sIn = preg_replace( '`^ICHT`', 'IKT', $sIn );
1251 ... $sIn = preg_replace( '`ORCHID`', 'ORKID', $sIn );
1252 ... $sIn = preg_replace( '`ONCHIO`', 'ONKIO', $sIn );
1253 ... $sIn = preg_replace( '`ACHIA`', 'AKIA', $sIn );			// retouche ACHIA -> AKIA
1254 ... $sIn = preg_replace( '`([^C])ANICH`', '$1ANIK', $sIn );	// ANICH -> ANIK 	1/2
1255 ... $sIn = preg_replace( '`OMANIK`', 'OMANICH', $sIn ); 	// cas particulier 	2/2
1256 ... $sIn = preg_replace( '`ACHY([^D])`', 'AKI$1', $sIn );
1257 ... $sIn = preg_replace( '`([AEIOU])C([BDFGJKLMNPQRTVWXZ])`', '$1K$2', $sIn ); // voyelle, C, consonne sauf H
1258 ... $convPrIn  = array('EUCHA','YCHIA','YCHA','YCHO','YCHED','ACHEO','RCHEO','RCHES',
1259 ... 'ECHN','OCHTO','CHORA','CHONDR','CHORE','MACHM','BRONCHO','LICHOS','LICHOC');
1260 ... $convPrOut = array('EKA',  'IKIA', 'IKA', 'IKO',  'IKED','AKEO','RKEO',  'RKES',
1261 ... 'EKN',  'OKTO', 'KORA', 'KONDR' ,'KORE' ,'MAKM', 'BRONKO', 'LIKOS', 'LIKOC');
1262 ... $sIn = str_replace( $convPrIn, $convPrOut, $sIn );
1263 ... 
1264 ... // Weuh (perfectible)
1265 ... $convPrIn  = array( 'WA','WO', 'WI','WHI','WHY','WHA','WHO');
1266 ... $convPrOut = array( 'OI', 'O','OUI','OUI','OUI','OUA', 'OU');
1267 ... $sIn = str_replace( $convPrIn, $convPrOut, $sIn );
1268 ... 
1269 ... // Gueu, Gneu, Jeu et quelques autres
1270 ... $convPrIn  = array( 'GNES','GNET','GNER','GNE',  'GI', 'GNI','GNA','GNOU','GNUR','GY','OUGAIN',
1271 ... 'AGEOL', 'AGEOT','GEOLO','GEOM','GEOP','GEOG','GEOS','GEORG','GEOR','NGEOT','UGEOT','GEOT','GEOD','GEOC','GEO','GEA','GE',
1272 ... 'QU', 'Q',  'CY', 'CI', 'CN','ICM','CEAT','CE',
1273 ... 'CR', 'CO', 'CUEI','CU', 'VENCA','CA', 'CS','CLEN','CL', 'CZ', 'CTIQ',
1274 ... 'CTIF','CTIC','CTIS','CTIL','CTIO','CTI', 'CTU', 'CTE','CTO','CTR','CT', 'PH', 'TH',
1275 ... 'OW', 'LH', 'RDL', 'CHLO', 'CHR', 'PTIA');
1276 ... $convPrOut = array( 'NIES','NIET','NIER', 'NE',  'JI',  'NI','NIA','NIOU','NIUR','JI','OUGIN',
1277 ... 'AJOL',  'AJOT','JEOLO','JEOM','JEOP','JEOG','JEOS','JORJ','JEOR','NJOT','UJOT','JEOT','JEOD','JEOC', 'JO','JA' ,'JE',
1278 ... 'K', 'K',  'SI', 'SI', 'KN','IKM', 'SAT','SE',
1279 ... 'KR', 'KO', 'KEI','KU', 'VANSA','KA', 'KS','KLAN','KL', 'KZ', 'KTIK',
1280 ... 'KTIF','KTIS','KTIS','KTIL','KSIO','KTI', 'KTU', 'KTE','KTO','KTR','KT', 'F',  'T',
1281 ... 'OU',  'L',  'RL',  'KLO',  'KR', 'PSIA');
1282 ... $sIn = str_replace( $convPrIn, $convPrOut, $sIn );
1283 ... 
1284 ... $sIn = preg_replace( '`GU([^RLMBSTPZN])`', 'G$1', $sIn ); // Gueu !
1285 ... $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // GNO ! Tout sauf S pour gnos
1286 ... $sIn = preg_replace( '`GNO([MLTNRKG])`', 'NIO$1', $sIn ); // bis -> gnognotte! Si quelqu'un sait le faire en une seule regexp...
1287 ... 
1288 ... 
1289 ... // TI -> SI v2.0
1290 ... $convPrIn  = array( 'BUTIE','BUTIA','BATIA','ANTIEL','RETION','ENTIEL','ENTIAL','ENTIO','ENTIAI','UJETION','ATIEM','PETIEN',
1291 ... 'CETIE','OFETIE','IPETI','LBUTION','BLUTION','LETION','LATION','SATIET');
1292 ... $convPrOut = array( 'BUSIE','BUSIA','BASIA','ANSIEL','RESION','ENSIEL','ENSIAL','ENSIO','ENSIAI','UJESION','ASIAM','PESIEN',
1293 ... 'CESIE','OFESIE','IPESI','LBUSION','BLUSION','LESION','LASION','SASIET');
1294 ... $sIn = str_replace( $convPrIn, $convPrOut, $sIn );
1295 ... $sIn = preg_replace( '`(.+)ANTI(AL|O)`', '$1ANSI$2', $sIn ); // sauf antialcoolique, antialbumine, antialarmer, ...
1296 ... $sIn = preg_replace( '`(.+)INUTI([^V])`', '$1INUSI$2', $sIn ); // sauf inutilité, inutilement, diminutive, ...
1297 ... $sIn = preg_replace( '`([^O])UTIEN`', '$1USIEN', $sIn ); // sauf soutien, ...
1298 ... $sIn = preg_replace( '`([^DE])RATI[E]$`', '$1RASI$2', $sIn ); // sauf xxxxxcratique, ...
1299 ... // TIEN TION -> SIEN SION v3.1
1300 ... $sIn = preg_replace( '`([^SNEU]|KU|KO|RU|LU|BU|TU|AU)T(IEN|ION)`', '$1S$2', $sIn );
1301 ... 
1302 ... 
1303 ... // H muet
1304 ... $sIn = preg_replace( '`([^CS])H`', '$1', $sIn ); 	// H muet
1305 ... $sIn = str_replace( "ESH", "ES", $sIn );			// H muet
1306 ... $sIn = str_replace( "NSH", "NS", $sIn );			// H muet
1307 ... $sIn = str_replace( "SH", "CH", $sIn );				// ou pas!
1308 ... 
1309 ... // NASALES
1310 ... $convNasIn  = array( 'OMT','IMB', 'IMP','UMD','TIENT','RIENT','DIENT','IEN',
1311 ... 'YMU','YMO','YMA','YME', 'YMI','YMN','YM', 'AHO','FAIM','DAIM','SAIM','EIN','AINS');
1312 ... $convNasOut = array( 'ONT','INB', 'INP','OND','TIANT','RIANT','DIANT', 'IN',
1313 ... 'IMU','IMO','IMA','IME', 'IMI','IMN','IN',  'AO', 'FIN','DIN', 'SIN','AIN','INS');
1314 ... $sIn = str_replace( $convNasIn, $convNasOut, $sIn );
1315 ... // AIN -> IN v2.0
1316 ... $sIn = preg_replace( '`AIN$`', 'IN', $sIn );
1317 ... $sIn = preg_replace( '`AIN([BTDK])`', 'IN$1', $sIn );
1318 ... // UN -> IN
1319 ... $sIn = preg_replace( '`([^O])UND`', '$1IND', $sIn ); // aucun mot français ne commence par UND!
1320 ... $sIn = preg_replace( '`([JTVLFMRPSBD])UN([^IAE])`', '$1IN$2', $sIn );
1321 ... $sIn = preg_replace( '`([JTVLFMRPSBD])UN$`', '$1IN', $sIn );
1322 ... $sIn = preg_replace( '`RFUM$`', 'RFIN', $sIn );
1323 ... $sIn = preg_replace( '`LUMB`', 'LINB', $sIn );
1324 ... // EN -> AN
1325 ... $sIn = preg_replace( '`([^BCDFGHJKLMNPQRSTVWXZ])EN`', '$1AN', $sIn );
1326 ... $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // deux fois pour les motifs recouvrants malentendu, pendentif, ...
1327 ... $sIn = preg_replace( '`([VTLJMRPDSBFKNG])EN([BRCTDKZSVN])`', '$1AN$2', $sIn ); // si quelqu'un sait faire avec une seule regexp!
1328 ... $sIn = preg_replace( '`^EN([BCDFGHJKLNPQRSTVXZ]|CH|IV|ORG|OB|UI|UA|UY)`', 'AN$1', $sIn );
1329 ... $sIn = preg_replace( '`(^[JRVTH])EN([DRTFGSVJMP])`', '$1AN$2', $sIn );
1330 ... $sIn = preg_replace( '`SEN([ST])`', 'SAN$1', $sIn );
1331 ... $sIn = preg_replace( '`^DESENIV`', 'DESANIV', $sIn );
1332 ... $sIn = preg_replace( '`([^M])EN(UI)`', '$1AN$2', $sIn );
1333 ... $sIn = preg_replace( '`(.+[JTVLFMRPSBD])EN([JLFDSTG])`', '$1AN$2', $sIn );
1334 ... // EI -> AI
1335 ... $sIn = preg_replace( '`([VSBSTNRLPM])E[IY]([ACDFRJLGZ])`', '$1AI$2', $sIn );
1336 ... 
1337 ... // Histoire d'Ã?
1338 ... $convNasIn  = array( 'EAU', 'EU',  'Y', 'EOI', 'JEA','OIEM','OUANJ','OUA','OUENJ');
1339 ... $convNasOut = array(   'O',  'E',  'I',  'OI', 'JA' ,'OIM' ,'OUENJ', 'OI','OUANJ');
1340 ... $sIn = str_replace( $convNasIn, $convNasOut, $sIn );
1341 ... $sIn = preg_replace( '`AU([^E])`', 'O$1', $sIn ); // AU sans E qui suit
1342 ... 
1343 ... // Les retouches!
1344 ... $sIn = preg_replace( '`^BENJ`', 'BINJ', $sIn );				// retouche BENJ -> BINJ
1345 ... $sIn = preg_replace( '`RTIEL`', 'RSIEL', $sIn );			// retouche RTIEL -> RSIEL
1346 ... $sIn = preg_replace( '`PINK`', 'PONK', $sIn );				// retouche PINK -> PONK
1347 ... $sIn = preg_replace( '`KIND`', 'KOND', $sIn );				// retouche KIND -> KOND
1348 ... $sIn = preg_replace( '`KUM(N|P)`', 'KON$1', $sIn );			// retouche KUMN KUMP
1349 ... $sIn = preg_replace( '`LKOU`', 'LKO', $sIn );				// retouche LKOU -> LKO
1350 ... $sIn = preg_replace( '`EDBE`', 'EBE', $sIn );				// retouche EDBE pied-bÅ?uf
1351 ... $sIn = preg_replace( '`ARCM`', 'ARKM', $sIn );				// retouche SCH -> CH
1352 ... $sIn = preg_replace( '`SCH`', 'CH', $sIn );					// retouche SCH -> CH
1353 ... $sIn = preg_replace( '`^OINI`', 'ONI', $sIn );				// retouche début OINI -> ONI
1354 ... $sIn = preg_replace( '`([^NDCGRHKO])APT`', '$1AT', $sIn );	// retouche APT -> AT
1355 ... $sIn = preg_replace( '`([L]|KON)PT`', '$1T', $sIn );		// retouche LPT -> LT
1356 ... $sIn = preg_replace( '`OTB`', 'OB', $sIn );					// retouche OTB -> OB (hautbois)
1357 ... $sIn = preg_replace( '`IXA`', 'ISA', $sIn );				// retouche IXA -> ISA
1358 ... $sIn = preg_replace( '`TG`', 'G', $sIn );					// retouche TG -> G
1359 ... $sIn = preg_replace( '`^TZ`', 'TS', $sIn );					// retouche début TZ -> TS
1360 ... $sIn = preg_replace( '`PTIE`', 'TIE', $sIn );				// retouche PTIE -> TIE
1361 ... $sIn = preg_replace( '`GT`', 'T', $sIn );					// retouche GT -> T
1362 ... $sIn = str_replace( "ANKIEM", "ANKILEM", $sIn );			// retouche tranquillement
1363 ... $sIn = preg_replace( "`(LO|RE)KEMAN`", "$1KAMAN", $sIn );	// KEMAN -> KAMAN
1364 ... $sIn = preg_replace( '`NT(B|M)`', 'N$1', $sIn );			// retouche TB -> B  TM -> M
1365 ... $sIn = preg_replace( '`GSU`', 'SU', $sIn );					// retouche GS -> SU
1366 ... $sIn = preg_replace( '`ESD`', 'ED', $sIn );					// retouche ESD -> ED
1367 ... $sIn = preg_replace( '`LESKEL`','LEKEL', $sIn );			// retouche LESQUEL -> LEKEL
1368 ... $sIn = preg_replace( '`CK`', 'K', $sIn );					// retouche CK -> K
1369 ... 
1370 ... // Terminaisons
1371 ... $sIn = preg_replace( '`USIL$`', 'USI', $sIn ); 				// terminaisons USIL -> USI
1372 ... $sIn = preg_replace( '`X$|[TD]S$|[DS]$`', '', $sIn );		// terminaisons TS DS LS X T D S...  v2.0
1373 ... $sIn = preg_replace( '`([^KL]+)T$`', '$1', $sIn );			// sauf KT LT terminal
1374 ... $sIn = preg_replace( '`^[H]`', '', $sIn );					// H pseudo muet en début de mot, je sais, ce n'est pas une terminaison
1375 ... $sBack2=$sIn;												// on sauve le code (utilisé pour les mots trÚs courts)
1376 ... $sIn = preg_replace( '`TIL$`', 'TI', $sIn );				// terminaisons TIL -> TI
1377 ... $sIn = preg_replace( '`LC$`', 'LK', $sIn );					// terminaisons LC -> LK
1378 ... $sIn = preg_replace( '`L[E]?[S]?$`', 'L', $sIn );			// terminaisons LE LES -> L
1379 ... $sIn = preg_replace( '`(.+)N[E]?[S]?$`', '$1N', $sIn );		// terminaisons NE NES -> N
1380 ... $sIn = preg_replace( '`EZ$`', 'E', $sIn );					// terminaisons EZ -> E
1381 ... $sIn = preg_replace( '`OIG$`', 'OI', $sIn );				// terminaisons OIG -> OI
1382 ... $sIn = preg_replace( '`OUP$`', 'OU', $sIn );				// terminaisons OUP -> OU
1383 ... $sIn = preg_replace( '`([^R])OM$`', '$1ON', $sIn );			// terminaisons OM -> ON sauf ROM
1384 ... $sIn = preg_replace( '`LOP$`', 'LO', $sIn );				// terminaisons LOP -> LO
1385 ... $sIn = preg_replace( '`NTANP$`', 'NTAN', $sIn );			// terminaisons NTANP -> NTAN
1386 ... $sIn = preg_replace( '`TUN$`', 'TIN', $sIn );				// terminaisons TUN -> TIN
1387 ... $sIn = preg_replace( '`AU$`', 'O', $sIn );					// terminaisons AU -> O
1388 ... $sIn = preg_replace( '`EI$`', 'AI', $sIn );					// terminaisons EI -> AI
1389 ... $sIn = preg_replace( '`R[DG]$`', 'R', $sIn );				// terminaisons RD RG -> R
1390 ... $sIn = preg_replace( '`ANC$`', 'AN', $sIn );				// terminaisons ANC -> AN
1391 ... $sIn = preg_replace( '`KROC$`', 'KRO', $sIn );				// terminaisons C muet de CROC, ESCROC
1392 ... $sIn = preg_replace( '`HOUC$`', 'HOU', $sIn );				// terminaisons C muet de CAOUTCHOUC
1393 ... $sIn = preg_replace( '`OMAC$`', 'OMA', $sIn );				// terminaisons C muet de ESTOMAC (mais pas HAMAC)
1394 ... $sIn = preg_replace( '`([J])O([NU])[CG]$`', '$1O$2', $sIn );// terminaisons C et G muet de OUC ONC OUG
1395 ... $sIn = preg_replace( '`([^GTR])([AO])NG$`', '$1$2N', $sIn );// terminaisons G muet ANG ONG sauf GANG GONG TANG TONG
1396 ... $sIn = preg_replace( '`UC$`', 'UK', $sIn );					// terminaisons UC -> UK
1397 ... $sIn = preg_replace( '`AING$`', 'IN', $sIn );				// terminaisons AING -> IN
1398 ... $sIn = preg_replace( '`([EISOARN])C$`', '$1K', $sIn );		// terminaisons C -> K
1399 ... $sIn = preg_replace( '`([ABD-MO-Z]+)[EH]+$`', '$1', $sIn );	// terminaisons E ou H sauf pour C et N
1400 ... $sIn = preg_replace( '`EN$`', 'AN', $sIn );					// terminaisons EN -> AN (difficile à faire avant sans avoir des soucis) Et encore, c'est pas top!
1401 ... $sIn = preg_replace( '`(NJ)EN$`', '$1AN', $sIn );			// terminaisons EN -> AN
1402 ... $sIn = preg_replace( '`^PAIEM`', 'PAIM', $sIn ); 			// PAIE -> PAI
1403 ... $sIn = preg_replace( '`([^NTB])EF$`', '\1', $sIn );			// F muet en fin de mot
1404 ... 
1405 ... $sIn = preg_replace( '`(.)\1`', '$1', $sIn ); 				// supression des répétitions (suite à certains remplacements)
1406 ... 
1407 ... // cas particuliers, bah au final, je n'en ai qu'un ici
1408 ... $convPartIn  = array( 'FUEL');
1409 ... $convPartOut = array( 'FIOUL');
1410 ... $sIn = str_replace( $convPartIn, $convPartOut, $sIn );
1411 ... 
1412 ... // Ce sera le seul code retourné à une seule lettre!
1413 ... if ($sIn=='O') return($sIn);
1414 ... 
1415 ... // seconde chance sur les mots courts qui ont souffert de la simplification
1416 ... if (strlen($sIn)<2)
1417 ... {
1418 ... 	// Sigles ou abréviations
1419 ... 	if (preg_match("`[BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ][BCDFGHJKLMNPQRSTVWXYZ]*`",$sBack))
1420 ... 		return($sBack);
1421 ... 
1422 ... 	if (preg_match("`[RFMLVSPJDF][AEIOU]`",$sBack))
1423 ... 	{
1424 ... 		if (strlen($sBack)==3)
1425 ... 			return(substr($sBack,0,2));// mots de trois lettres supposés simples
1426 ... 		if (strlen($sBack)==4)
1427 ... 			return(substr($sBack,0,3));// mots de quatre lettres supposés simples
1428 ... 	}
1429 ... 
1430 ... 	if (strlen($sBack2)>1) return $sBack2;
1431 ... }
1432 ... 
1433 ... if (strlen($sIn)>1)
1434 ... 	return substr($sIn,0,16); // Je limite à 16 caractÚres mais vous faites comme vous voulez!
1435 ... else
1436 ... 	return '';
1437 ... }
1438 ... 
1439 ... /* ========================================================================== */
1440 ... /** {{*STR_aClasses( $szStr,$szKeyword )=
1441 ... 
1442 ...     Extracts the start and stop position of the classes contained
1443 ...     in a source code
1444 ... 
1445 ...     {*params
1446 ...         $szStr      (string)    The source code string to process. Passed
1447 ...                                 by reference but NOT touched.
1448 ...         $szKeyword  (string)    Keyword to look for. Optional. [c]'class'[/c]
1449 ...                                 by default.
1450 ...     *}
1451 ... 
1452 ...     {*return
1453 ...         (array)     An array of start and stop position per class
1454 ...     *}
1455 ... 
1456 ...     {*exec
1457 ...     [include]__DIR__/ut/strings.aclasses.example.php[/include]
1458 ...     *}
1459 ... 
1460 ...     *}}
1461 ...  */
1462 ... /* ========================================================================== */
1463 ... function STR_aClasses( &$szStr,$szKeyword = 'class' )
1464 ... /*-------------------------------------------------*/
1465 ... {
1466 ...     $aClasses       = array();                                      /* Return value of the function */
1467 ...     $iPos           = 0;                                            /* Current position */
1468 ...     $iLength        = strlen( $szStr );                             /* Length fo string to process */
1469 ... 
1470 ...     $InComment      = false;                                        /* Not in a comment */
1471 ...     $InString       = false;                                        /* Not in a string */
1472 ...     $InClass        = false;                                        /* Not in a class */
1473 ...     $cBef           =                                               /* Character before */
1474 ...     $cBal           = null;                                         /* String balancer (either ' or ") */
1475 ...     $szWord         = '';                                           /* Last full word read */
1476 ...     $OneLineComment = false;                                        /* One-line comment ( // or #) */
1477 ...     $iLevel         = -1;                                           /* Curly brace level ({ and }) : invalid value for now */
1478 ... 
1479 ... 
1480 ... 
1481 ...     while ( $iPos < $iLength )                                      /* While we haven't treated the whole source code */
1482 ...     {
1483 ...         $c = $szStr[$iPos++];                                       /* Character we just read */
1484 ...         //echo $c,'/';
1485 ... 
1486 ...         /* If we're in a ONE-LINE comment and char is a CR or LF */
1487 ...         if ( $OneLineComment && ( $c === chr(13) || $c === chr(10) ) )
1488 ...         {
1489 ...             $InComment      = false;                                /* This terminates the comment */
1490 ...             $OneLineComment = false;
1491 ...         }
1492 ... 
1493 ...         if ( ! $InString )                                          /* If we are NOT in the middle of a string */
1494 ...         {
1495 ...             /* If character is a forward slash AND next char is a star */
1496 ...             if     ( $c === '/' && $iPos < $iLength && $szStr[$iPos] === '*' )
1497 ...             {
1498 ...                 //echo "<p>Start of a comment with $c</p>";
1499 ...                 $InComment = true;                                  /* Then ... we start a comment */
1500 ...             }
1501 ...             /* If character is a star AND next char is a forward slash */
1502 ...             elseif ( $c === '*' && $iPos < $iLength && $szStr[$iPos] === '/' )
1503 ...             {
1504 ...                 $InComment = false;                                 /* Then ... the comment just stopped */
1505 ...             }
1506 ...             elseif ( ( ! $InComment && ( ( $c === '/' && $iPos < $iLength && $szStr[$iPos] === '/' ) || $c === '#' ) ) ) /* If // or # */
1507 ...             {
1508 ...                 //echo "<p>Start of a comment with $c</p>";
1509 ...                 $InComment = true;                                  /* Then ... the comment just started */
1510 ...                 $OneLineComment = true;                             /* Remember it is a ONE-LINE comment */
1511 ...             }
1512 ... 
1513 ...             if ( ! $InComment )                                     /* If we're NOT in a comment - and also NOT in a string */
1514 ...             {
1515 ...                 if ( $c === '\'' || $c === '"' )                    /* If we just read a ' or a " */
1516 ...                 {
1517 ...                     //echo "<p>Start of a string with $c</p>";
1518 ...                     $InString = true;                               /* Then a string starts */
1519 ...                     $cBal = $c;                                     /* Remember that this string must be balanced with exactly the same char */
1520 ...                 }
1521 ...             }
1522 ...         }
1523 ...         else    /* MIDDLE OF A STRING ... MIDDLE OF A STRING ... MIDDLE OF A STRING ...  */
1524 ...         {
1525 ...             if ( $c === $cBal && true )                    /* If char == string balancer AND char before not a backslash */
1526 ...             {
1527 ...                 //echo "<p>Potential end of a string with $c</p>";
1528 ...                 if ( $cBef != '\\' || $szStr[$iPos-3] == '\\' )
1529 ...                 {
1530 ...                     //echo "<p>End of a string with $c</p>";
1531 ...                     $InString = false;                                  /* This is the end of the string */
1532 ...                     $cBal = null;                                       /* Reset the string balancer */
1533 ...                 }
1534 ...             }
1535 ...         }
1536 ... 
1537 ...         if ( ! $InString && ! $InComment )                          /* NOW ... we're NOT in a string and NOT in a comment ... this must be language */
1538 ...         {
1539 ...             /* If char not a blank, not a tab, not a CR, not a LF,
1540 ...                not a minus sign, not a plus sign, not a slash,
1541 ...                not a backslash, not a star ...
1542 ...             */
1543 ...             if ( $c != ' ' && $c != chr(9) && $c != chr(10) && $c != chr(13) && $c != '-' && $c != '+' && $c != '/' && $c != '\\' && $c != '*' )
1544 ...             {
1545 ...                 $szWord .= $c;                                      /* Concatenate full word (no need to use further intelligence) */
1546 ... 
1547 ...                 if ( $InClass )                                     /* If we're in a class */
1548 ...                 {
1549 ...                     if ( $c === '{' )
1550 ...                     {
1551 ...                         if ( $iLevel === -1 )
1552 ...                         {
1553 ...                             $iLevel = 1;
1554 ...                             //echo "<p>Niveau 1 des {}</p>";
1555 ...                         }
1556 ...                         else
1557 ...                         {
1558 ...                             $iLevel++;
1559 ...                             //echo "<p>Niveau {$iLevel} des {}</p>";
1560 ...                         }
1561 ...                     }
1562 ...                     elseif ( $c === '}' )
1563 ...                     {
1564 ...                         $iLevel--;
1565 ...                         //echo "<p>Niveau {$iLevel} des {}</p>";
1566 ...                     }
1567 ... 
1568 ...                     if ( $iLevel === 0 )
1569 ...                     {
1570 ...                         //die("BOUM");
1571 ...                         $aClasses[count($aClasses)-1] = array($aClasses[count($aClasses)-1][0],$iPos - 1);
1572 ...                         $iLevel = -1;
1573 ...                         $InClass = false;
1574 ...                     }
1575 ...                 }
1576 ...             }
1577 ...             else                                                    /* We have read a token stopper (a blank, a tab, a ...) */
1578 ...             {
1579 ...                 //echo 'TOKEN STOPPER met; current word is <code>',$szWord,'</code></br>';
1580 ...                 if ( $szWord === $szKeyword && ! $InClass )         /* If the full word we just read is 'class' or 'interface' or 'trait' AND if not already in a class */
1581 ...                 {
1582 ...                     //echo 'KEYWORD MATCH: STORE POSITION!!!<br/>';
1583 ...                     /* Store where this class starts -- no need to know its name */
1584 ...                     $aClasses[] = array( $iPos - strlen( $szWord ) - 1,-1 );
1585 ...                     $InClass = true;                                /* Remember that we're in a class now */
1586 ...                     $iLevel = -1;                                   /* And set the { and } level to an invalid value */
1587 ...                 }   /* if ( $szWord === $szKeyword ) */
1588 ... 
1589 ...                 $szWord = '';                                       /* We've read a token stopper ... reset word */
1590 ...             }
1591 ...         }   /* if ( ! $InString && ! $InComment ) */
1592 ... 
1593 ...         $cBef = $c;                                                 /* Character before is the one we just read ! */
1594 ...     }   /* while ( $iPos < $iLength ) */
1595 ... 
1596 ...     return ( $aClasses );
1597 ... }   /* == End of function STR_aClasses() ==================================== */
1598 ... 
1599 ... /* ========================================================================== */
1600 ... /** {{*STR_Minify( $szStr,$szKeyword )=
1601 ... 
1602 ...     Extracts the start and stop position of the classes contained
1603 ...     in a source code
1604 ... 
1605 ...     {*params
1606 ...         $szStr      (string)    The source code string to process. Passed
1607 ...                                 by reference but NOT touched.
1608 ...         $szKeyword  (string)    Keyword to look for. Optional. [c]'class'[/c]
1609 ...                                 by default.
1610 ...     *}
1611 ... 
1612 ...     {*return
1613 ...         (array)     An array of start and stop position per class
1614 ...     *}
1615 ... 
1616 ...     {*exec
1617 ...         [include]__DIR__/ut/strings.aclasses.example.php[/include]
1618 ...     *}
1619 ... 
1620 ...     *}}
1621 ...  */
1622 ... /* ====================================================================== */
1623 ... function STR_Minify( $szStr,$szKeyword = 'class' )
1624 ... /*-----------------------------------------------*/
1625 ... {
1626 ...     $iPos           = 0;                                            /* Current position */
1627 ...     $iLength        = strlen( $szStr );                             /* Length fo string to process */
1628 ... 
1629 ...     $InComment      = false;                                        /* Not in a comment */
1630 ...     $InString       = false;                                        /* Not in a string */
1631 ...     $InClass        = false;                                        /* Not in a class */
1632 ...     $cBef           =                                               /* Character before */
1633 ...     $cBal           = null;                                         /* String balancer (either ' or ") */
1634 ...     $szCode         = '';                                           /* Code that is minified and consecutive spaces reduced to 1 */
1635 ...     $OneLineComment = false;                                        /* One-line comment ( // or #) */
1636 ... 
1637 ...     while ( $iPos < $iLength )                                      /* While we haven't treated the whole source code */
1638 ...     {
1639 ...         $cNext = '';
1640 ...         $c = $szStr[$iPos++];                                       /* Character we just read */
1641 ... 
1642 ...         //if ( $c === "\r" )
1643 ...         //    $c = "\n";
1644 ...         ////echo $c,'/';
1645 ...         //
1646 ...         //if ( $iPos < $iLength )
1647 ...         //{
1648 ...         //    $cNext = $szStr[$iPos];
1649 ...         //    if ( $c === "\n" && ( $cNext === "\r" || $cNext === "\n" ) )
1650 ...         //    {
1651 ...         //        //echo "TWO CR";
1652 ...         //        continue;
1653 ...         //    }
1654 ...         //}
1655 ... 
1656 ...         /* If we're in a ONE-LINE comment and char is a CR or LF */
1657 ...         if ( $OneLineComment && ( $c === "\n" ) )
1658 ...         {
1659 ...             $InComment      = false;                                /* This terminates the comment */
1660 ...             $OneLineComment = false;
1661 ...         }
1662 ... 
1663 ... 
1664 ... 
1665 ...         if ( ! $InString ) /* IF NOT IN A STRING */
1666 ...         {
1667 ...             /* If character is a forward slash AND next char is a star */
1668 ...             if     ( $c === '/' && $iPos < $iLength && $szStr[$iPos] === '*' )
1669 ...             {
1670 ...                 //echo "<p>Start of a comment with $c</p>";
1671 ...                 $InComment = true;                                  /* Then ... we start a comment */
1672 ...             }
1673 ...             /* If character is a star AND next char is a forward slash */
1674 ...             elseif ( $c === '*' && $iPos < $iLength && $szStr[$iPos] === '/' )
1675 ...             {
1676 ...                 $c = ''; $iPos++;
1677 ...                 $InComment = false;                                 /* Then ... the comment just stopped */
1678 ...             }
1679 ...             elseif ( ( ! $InComment && ( ( $c === '/' && $iPos < $iLength && $szStr[$iPos] === '/' ) || $c === '#' ) ) ) /* If // or # */
1680 ...             {
1681 ...                 //echo "<p>Start of a comment with $c</p>";
1682 ...                 $InComment = true;                                  /* Then ... the comment just started */
1683 ...                 $OneLineComment = true;                             /* Remember it is a ONE-LINE comment */
1684 ...             }
1685 ... 
1686 ...             if ( ! $InComment )                                     /* If we're NOT in a comment - and also NOT in a string */
1687 ...             {
1688 ...                 if ( $c === '\'' || $c === '"' )                    /* If we just read a ' or a " */
1689 ...                 {
1690 ...                     //echo "<p>Start of a string with $c</p>";
1691 ...                     $InString = true;                               /* Then a string starts */
1692 ...                     $cBal = $c;                                     /* Remember that this string must be balanced with exactly the same char */
1693 ...                 }
1694 ...             }
1695 ...         }
1696 ...         else    /* MIDDLE OF A STRING ... MIDDLE OF A STRING ... MIDDLE OF A STRING ...  */
1697 ...         {
1698 ...             if ( $c === $cBal && true )                    /* If char == string balancer AND char before not a backslash */
1699 ...             {
1700 ...                 //echo "<p>Potential end of a string with $c</p>";
1701 ...                 if ( $cBef != '\\' || $szStr[$iPos-3] == '\\' )
1702 ...                 {
1703 ...                     //echo "<p>End of a string with $c</p>";
1704 ...                     $InString = false;                              /* This is the end of the string */
1705 ...                     $cBal = null;                                   /* Reset the string balancer */
1706 ...                 }
1707 ...             }
1708 ...         }
1709 ... 
1710 ...         if ( ! $InComment )
1711 ...         //if ( ! $InString && ! $InComment )                          /* NOW ... we're NOT in a string and NOT in a comment ... this must be code */
1712 ...         {
1713 ...             if ( $c === "\t" )
1714 ...                 $c = ' ';
1715 ...             elseif ( $c === "\r" )
1716 ...                 $c = "\n";
1717 ... 
1718 ...             $cCharToAdd = $c;                                       /* Char we're adding to the code that we keep */
1719 ...             //echo "<p>POS: <code>$iPos</code>; C: <code>'$c'</code>",ord($c),"; CBEF: <code>'$cBef'</code>",ord($cBef),"</p>";
1720 ... 
1721 ...             if ( ! $InString )                                      /* If not in a string */
1722 ...             {
1723 ...                 /* See if we can reduce the output */
1724 ...                 if ( $cBef === ' '  && $c === ' '   ||
1725 ...                      $cBef === "\n" && $c === "\n"  ||
1726 ...                      $cBef === "\n" && $c === ''    ||
1727 ...                      $cBef === ''   && $c === ' '   // ||
1728 ...                      //$cBef === ''   && $c === "\n"
1729 ...                    )
1730 ...                 {
1731 ...                     $cCharToAdd = '';
1732 ...                 }
1733 ...                 elseif ( $cBef === "\n" && $c === ' ' )
1734 ...                 {
1735 ...                     $cCharToAdd = '';
1736 ...                 }
1737 ...                 //elseif ( $cBef === "\n" && $c === ' ' )
1738 ...                 //{
1739 ...                 //    $cCharToAdd = '&#171;';
1740 ...                 //}
1741 ...             }
1742 ... 
1743 ...             //if ( $cCharToAdd === "\n" )
1744 ...             //    $cCharToAdd = "&#182\n";
1745 ... 
1746 ...             $szCode .= $cCharToAdd;
1747 ...         }   /* if ( ! $InString && ! $InComment ) */
1748 ... 
1749 ...         $cBef = $c;                                                 /* Character before is the one we just read ! */
1750 ...     }   /* while ( $iPos < $iLength ) */
1751 ... 
1752 ...     return ( $szCode );
1753 ... }   /* == End of function STR_Minify() ================================ */
1754 ... 
1755 ... /* ====================================================================== */
1756 ... /** {{*STR_SyntaxColoring( $szLine,$aColors )=
1757 ... 
1758 ...     Syntax coloring of a string
1759 ... 
1760 ...     {*params
1761 ...         $szLine     (string)    The source code string to process. Passed
1762 ...                                 by reference but NOT touched.
1763 ...         $aColors    (array)     Associative array of colors that must be
1764 ...                                 used:[br]
1765 ...                                 [c]$aColors['strings'][/c][br]
1766 ...                                 [c]$aColors['vars'][/c][br]
1767 ...                                 [c]$aColors['comments'][/c][br]
1768 ...     *}
1769 ... 
1770 ...     {*return
1771 ...         (string)        $szLine with styling included
1772 ...     *}
1773 ... 
1774 ...     {*noassert *}
1775 ... 
1776 ...     {*example
1777 ...         $aSyntaxColors              = array();
1778 ...         $aSyntaxColors['vars']      = 'red';
1779 ...         $aSyntaxColors['strings']   = 'blue';
1780 ...         $aSyntaxColors['comments']  = 'rgb(197,98,49)';
1781 ... 
1782 ...         echo '<pre>';
1783 ...         echo STR_SyntaxColoring( $szSourceCode,$aSyntaxColors );
1784 ...         echo '</pre>';
1785 ...     *}
1786 ... 
1787 ...     *}}
1788 ...  */
1789 ... /* ========================================================================== */
1790 ... function STR_SyntaxColoring( &$szLine,$aColors )
1791 ... /*--------------------------------------------*/
1792 ... {
1793 ...     $aPatterns      = array( '/((?P<str1>\'[^"]*\')|(?P<str2>"[^"]*"))/s',  /* String literals  */
1794 ...                              '/(\${1}[[:alnum:]_]*\b)/i'                 ,  /* Variables */
1795 ...                              '%/\*(.*?)\*/%'                                /* Comments */
1796 ...                            );
1797 ...     $aSubstitutes   = array( '<em style="color:' . $aColors['strings']  . ';">\1</em>'    ,
1798 ...                              '<em style="color:' . $aColors['vars']     . ';">\1</em>'    ,
1799 ...                              '<em style="color:' . $aColors['comments'] . ';">/*\1*/</em>'
1800 ...                            );
1801 ...     $szRetVal = preg_replace( $aPatterns,$aSubstitutes,$szLine );
1802 ... 
1803 ...     return ( $szRetVal );
1804 ... }   /* == End of function STR_SyntaxColoring() ============================== */
1805 ... 
1806 ... function STR_Uncomment( $szStr )
1807 ... /*----------------------------*/
1808 ... {
1809 ...     return ( preg_replace( '%/\*(.+?)\*/%si','',$szStr ) );
1810 ... }
1811 ... 
1812 ... /* ========================================================================== */
1813 ... /** {{*STR_shl( $szStr,$nBits )=
1814 ... 
1815 ...     Shifts-Left a string by a given number of [b]bits[/b] ($nBits).
1816 ... 
1817 ...     {*params
1818 ...         $szStr  (string)    The string that must be left shifted
1819 ...         $nBits    (int)       Number of bits to shift the string by.
1820 ...                             Minimum 1 bit, maximum 7 bits.
1821 ...     *}
1822 ... 
1823 ...     {*remark
1824 ...         STR_shl() can be one useful component of an encryption algorithm.
1825 ...     *}
1826 ... 
1827 ...     {*return
1828 ...         (string)   $szStr left-shifted by $nBits
1829 ...     *}
1830 ... 
1831 ...     {*assert
1832 ...         STR_shl( 'Hello',3 ) === 'C+ccz'
1833 ...     *}
1834 ... 
1835 ...     {*seealso
1836 ...         STR_shr()
1837 ...     *}
1838 ... 
1839 ...     {*example
1840 ...         echo '<p>Shifted left: ' . ( $szLShifted = STR_shl( 'Hello',3 ) ) . '</p>'; // Prints 'C+ccz'
1841 ...         echo '<p>Shifted back to right: ' . STR_shr( $szLShifted,3 ) . '</p>';      // Prints 'Hello'
1842 ...     *}
1843 ...     *}}
1844 ...  */
1845 ... /* ========================================================================== */
1846 ... function STR_shl( $szStr,$nBits )
1847 ... /*-----------------------------*/
1848 ... {
1849 ...     if ( $nBits < 1 || $nBits > 7 )                                 /* If not adequate number of bits */
1850 ...     {
1851 ...         return ( $szStr );                                          /* Return the original string */
1852 ...     }   /* if ( $nBits < 1 || $nBits > 7 ) */
1853 ... 
1854 ...     if ( ( $iLength = strlen( $szStr ) ) <= 0 )                     /* If string empty */
1855 ...     {
1856 ...         return ( $szStr );                                          /* Return the original string */
1857 ...     }   /* if ( ( $iLength = strlen( $szStr ) ) <= 0 ) */
1858 ... 
1859 ...     $szRetVal   = '';                                               /* Create an empty string */
1860 ... 
1861 ...     $szBits     = STR_Binary( $szStr );                             /* $szStr in bits */
1862 ...     $szLostBits = STR_Left( $szBits,$nBits );                       /* The $nBits leftmost bits of the string */
1863 ...     $szShifted  = substr( $szBits,$nBits ) . $szLostBits;           /* $szStr left shifted */
1864 ... 
1865 ...     for ( $i = 0;$i < $iLength;$i++ )                               /* Treat the entire string (per slice of 8 bits) */
1866 ...     {
1867 ...         $szRetVal .= chr( bindec( substr( $szShifted,$i * 8,8 ) ) );/* Concatenate the CHR to the result string */
1868 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
1869 ... 
1870 ...     return ( $szRetVal );                                           /* Return result to caller */
1871 ... }   /* == End of function STR_shl() ========================================= */
1872 ... 
1873 ... /* This is the EXACT implementation of the quicksort algorithm BUT it sucks in
1874 ...    PHP. You reach very quickly the nesting limit of 256 levels ...
1875 ... 
1876 ...     // 20160616 -- function STR_quickSort( &$szStr,$iFirst,$iLast )
1877 ...     // 20160616 -- {
1878 ...     // 20160616 --     $iPivot = $j = $i = 0;
1879 ...     // 20160616 --     $cTemp = null;
1880 ...     // 20160616 --
1881 ...     // 20160616 --     if ( $iFirst < $iLast )
1882 ...     // 20160616 --     {
1883 ...     // 20160616 --         $iPivot = $iFirst;
1884 ...     // 20160616 --         //echo "<p>START: <code>",$szStr,"</code></p>\n";
1885 ...     // 20160616 --
1886 ...     // 20160616 --         $i = $iFirst;
1887 ...     // 20160616 --         $j = $iLast;
1888 ...     // 20160616 --
1889 ...     // 20160616 --         while ( $i < $j )
1890 ...     // 20160616 --         {
1891 ...     // 20160616 --             while( $szStr[$i] <= $szStr[$iPivot] && $i < $iLast )
1892 ...     // 20160616 --             {
1893 ...     // 20160616 --                 $i++;
1894 ...     // 20160616 --             }
1895 ...     // 20160616 --
1896 ...     // 20160616 --             while ( $szStr[$j] > $szStr[$iPivot] )
1897 ...     // 20160616 --             {
1898 ...     // 20160616 --                 $j--;
1899 ...     // 20160616 --             }
1900 ...     // 20160616 --
1901 ...     // 20160616 --             if ( $i < $j )
1902 ...     // 20160616 --             {
1903 ...     // 20160616 --                 $cTemp     = $szStr[$i];
1904 ...     // 20160616 --                 $szStr[$i] = $szStr[$j];
1905 ...     // 20160616 --                 $szStr[$j] = $cTemp;
1906 ...     // 20160616 --             }
1907 ...     // 20160616 --         }
1908 ...     // 20160616 --
1909 ...     // 20160616 --         $cTemp = $szStr[$iPivot];
1910 ...     // 20160616 --
1911 ...     // 20160616 --         $szStr[$iPivot] = $szStr[$j];
1912 ...     // 20160616 --         $szStr[$j]      = $cTemp;
1913 ...     // 20160616 --
1914 ...     // 20160616 --         //echo "<p>APRÃ?S: <code>",$szStr,"</code></p>\n";
1915 ...     // 20160616 --
1916 ...     // 20160616 --         STR_quickSort( $szStr,$iFirst,$j-1   );
1917 ...     // 20160616 --         STR_quickSort( $szStr,$j+1   ,$iLast );
1918 ...     // 20160616 --     }
1919 ...     // 20160616 --
1920 ...     // 20160616 --     return ( $szStr );
1921 ...     // 20160616 -- }
1922 ... 
1923 ...     Instead ... use this easy trick:
1924 ... 
1925 ...     1) Convert a string into an array (str_split())
1926 ...     2) Sort the array (sort())
1927 ...     3) Recompose the string (implode())
1928 ... 
1929 ...     IT IS A MAGNITUDE FASTER ... AND YOU DON'T BANG INTO THE PROBLEM OF THE
1930 ...     LIMIT OF THE NESTING LEVELS
1931 ... */
1932 ... /* ========================================================================== */
1933 ... /** {{*STR_Sort( $szStr )=
1934 ... 
1935 ...     Sorts a string
1936 ... 
1937 ...     {*params
1938 ...         $szStr  (string)    The string that must be sorted
1939 ...     *}
1940 ... 
1941 ...     {*return
1942 ...         (string)   $szStr soothed with $cChar
1943 ...     *}
1944 ... 
1945 ...     {*assert
1946 ...         STR_Sort( 'BOENS' ) === 'BENOS'
1947 ...     *}
1948 ... 
1949 ...     {*assert
1950 ...         STR_Sort( 'LATO SENSU MANAGEMENT' ) === '  AAAEEEGLMMNNNOSSTTU'
1951 ...     *}
1952 ... 
1953 ...     {*assert
1954 ...         STR_Sort( 'QUITUS' ) === 'IQSTUU'
1955 ...     *}
1956 ... 
1957 ...     *}}
1958 ...  */
1959 ... /* ========================================================================== */
1960 ... function STR_Sort( $szStr )
1961 ... /*-----------------------*/
1962 ... {
1963 ...     $szStr = mb_convert_encoding( $szStr,'Windows-1252' );
1964 ... 
1965 ...     $aStr = str_split( $szStr );
1966 ...     sort( $aStr );
1967 ...     return ( mb_convert_encoding( implode( '',$aStr ) ,'UTF-8','Windows-1252' ) );
1968 ... }   /* == End of function STR_Sort() ======================================== */
1969 ... 
1970 ... /*
1971 ... Il y a aussi des cas où 2 caractÚres peuvent être pris pour 1 seul:
1972 ... "li" peut être pris pour "h"
1973 ... 
1974 ... 
1975 ... a,8,g
1976 ... c,e,t
1977 ... û,0,O,D
1978 ... 
1979 ... B,8,E,â?¬
1980 ... 
1981 ... Q,R
1982 ... 
1983 ... J,U
1984 ... 
1985 ... I,T,1,L,C
1986 ... 
1987 ... H,M
1988 ... 
1989 ... S,5,$
1990 ... 
1991 ... V,W
1992 ... 
1993 ... 
1994 ... 
1995 ... */
1996 ... 
1997 ... function OCRMatch( $szStr1,$szStr2 )
1998 ... /*--------------------------------*/
1999 ... {
2000 ...     echo "<p>STRING1 (BEFORE): ",$szStr1,"</p>\n";
2001 ...     echo "<p>STRING2 (BEFORE): ",$szStr2,"</p>\n";
2002 ... 
2003 ...     $szOut1 = OCRCompile( $szStr1 );
2004 ...     $szOut2 = OCRCompile( $szStr2 );
2005 ... 
2006 ...     echo "<p>STRING1 (AFTER): ",$szOut1,"</p>\n";
2007 ...     echo "<p>STRING2 (AFTER): ",$szOut2,"</p>\n";
2008 ... 
2009 ...     echo "<p>LEVENSHTEIN: ",levenshtein( $szOut1,$szOut2 ),"</p>\n";
2010 ... 
2011 ...     //$szStr1 = mb_strtoupper( $szStr1 );
2012 ...     //$szStr2 = mb_strtoupper( $szStr2 );
2013 ...     //
2014 ...     //echo "<p>STRING1: ",$szStr1,"</p>\n";
2015 ...     //echo "<p>STRING2: ",$szStr2,"</p>\n";
2016 ... }
2017 ... 
2018 ... /* ========================================================================== */
2019 ... /** {{*STR_MatchingWords( $szWord[[,$szLang = 'fr'],$iRequiredRank])=
2020 ... 
2021 ...     Return all words that are close to $szWord from a character perspective
2022 ...     (not meaning). In general it contains a number of collisions that can
2023 ...     be quickly disregarded based on their ranking. The function returns an
2024 ...     XML string
2025 ... 
2026 ...     {*params
2027 ...         $szWord         (string)    The word whose siblings must be returned
2028 ...         $szLang         (string)    Optional. The language to consider (only French
2029 ...                                     for the time being - 22-07-16 11:26:27)
2030 ...         $iRequiredRank  (int)       Optional. The ranking filter (every word 
2031 ...                                     whose ranking is lower or equal to 
2032 ...                                     $iRequiredRank will be returned in the 
2033 ...                                     XML)
2034 ...     *}
2035 ...     
2036 ...     {*warning
2037 ...         Only French words are treated so far (22-07-16 11:26:01)
2038 ...     *}
2039 ... 
2040 ...     {*return
2041 ...         (string)   an XML string that lists all siblings
2042 ...     *}
2043 ... 
2044 ...     *}}
2045 ...  */
2046 ... /* ========================================================================== */
2047 ... function STR_MatchingWords( $szWord,$szLang = 'fr',$iRequiredRank = 5 )
2048 ... /*-------------------------------------------------------------------*/
2049 ... {
2050 ...     static $aHash = null;
2051 ...     $szXML = null;                                                  /* Return value of the function */
2052 ... 
2053 ...     switch( $szLang )
2054 ...     {
2055 ...         default :   $szDictionary = __DIR__ . '/../resources/words/french-words.hash';
2056 ...     }   /* switch( $szLang ) */
2057 ... 
2058 ...     //echo "<p>{$szDictionary} for {$szWord}</p>\n";
2059 ... 
2060 ...     // ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... 
2061 ...     // ATTENTION, CELA NE VA MARCHER TEL QUEL QU'AVEC UNE SEULE LANGUE
2062 ...     // CAR SI ON CHANGE DE LANGUE ENTRE DEUX APPELS, ON SE RETROUVE AVEC
2063 ...     // LE PREMIER DICTIONNAIRE CHARGE
2064 ...     // ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... ATTENTION ... 
2065 ...     if ( is_null( $aHash ) )
2066 ...     {
2067 ...         // Load French words
2068 ...         $aHash = unserialize( FIL_FileToStr( $szDictionary ) );
2069 ...     }   /* if ( is_null( $aHash ) ) */
2070 ... 
2071 ...     // If hash of word found
2072 ...     if ( isset( $aHash[$szHash = STR_hash( $szWord )] ) )
2073 ...     {
2074 ...         $iMatches = 0;
2075 ...         $szWordRegEx = preg_replace('/[\x41\x45\x49\x4F\x55\x59\x61\x65\x69\x6F\x75\x79\xC0\xC1\xC2\xC3\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD2\xD3\xD4\xD5\xD6\xD9\xDA\xDB\xDC\xDD\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF2\xF3\xF4\xF5\xF6\xF9\xFA\xFB\xFC\xFD]/','',mb_convert_encoding( $szWord,'Windows-1252','UTF-8' ) );
2076 ... 
2077 ...         $szXML  = '<?xml version="1.0" encoding="UTF-8"?>';
2078 ...         $szXML .= "<MatchingWords>\n";
2079 ...             $szXML .= "<Original strip-vowels=\"{$szWordRegEx}\"><![CDATA[{$szWord}]]></Original>\n";
2080 ...             $szXML .= "<Warning><![CDATA[Only French words for the time being!]]></Warning>\n";
2081 ...             $szXML .= "<Response number-of-matches=\"---COUNT---\">\n";
2082 ... 
2083 ...             foreach( $aHash[$szHash] as $szCollision )
2084 ...             {
2085 ...                 $szCollisionRegEx = preg_replace('/[\x41\x45\x49\x4F\x55\x59\x61\x65\x69\x6F\x75\x79\xC0\xC1\xC2\xC3\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD2\xD3\xD4\xD5\xD6\xD9\xDA\xDB\xDC\xDD\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF2\xF3\xF4\xF5\xF6\xF9\xFA\xFB\xFC\xFD]/', '',mb_convert_encoding( $szCollision,'Windows-1252','UTF-8' ) );
2086 ... 
2087 ...                 if ( strtolower( $szCollision ) === strtolower( $szWord ) )
2088 ...                 {
2089 ...                     $iRank      = 1;
2090 ...                     $iDistance  = 0;
2091 ...                 }   /* if ( $szCollision == $szWord ) */
2092 ...                 else    /* Else of ... if ( $szCollision == $szWord ) */
2093 ...                 {
2094 ... 
2095 ...                     // The regular expression removes ALL accents
2096 ...                     switch( $iDistance = levenshtein( strtolower( $szCollisionRegEx ),strtolower( $szWordRegEx ) ) )
2097 ...                     {
2098 ...                         case 0  : $iRank = 2;
2099 ...                                   break;
2100 ... 
2101 ...                         case 1  :
2102 ...                         case 2  : $iRank = 3;
2103 ...                                   break;
2104 ... 
2105 ...                         case 3  :
2106 ...                         case 4  :
2107 ...                         case 5  : $iRank = 3;
2108 ...                                   break;
2109 ... 
2110 ...                         case 6  :
2111 ...                         case 7  :
2112 ...                         case 8  :
2113 ...                         case 9  : $iRank = 4;
2114 ...                                   break;
2115 ... 
2116 ...                         default : $iRank = 5;
2117 ...                     }
2118 ...                 }   /* End of ... Else of ... if ( $szCollision == $szWord ) */
2119 ... 
2120 ...                 if ( $iRank <= $iRequiredRank )
2121 ...                 {
2122 ...                     $iMatches++;
2123 ...                     $szXML .= "<Lemma strip-vowels=\"{$szCollisionRegEx}\" distance=\"{$iDistance}\" rank=\"{$iRank}\"><![CDATA[{$szCollision}]]></Lemma>\n";
2124 ...                 }   /* if ( $iRank <= $iRequiredRank ) */
2125 ...             }   /* foreach( $aHash[$szHash] as $szCollision ) */
2126 ... 
2127 ...             $szXML .= "</Response>\n";
2128 ...         $szXML .= "</MatchingWords>\n";
2129 ... 
2130 ...         if ( $iMatches < 1 )
2131 ...         {
2132 ...             $szXML = null;
2133 ...         }
2134 ...         else
2135 ...         {
2136 ...             $szXML = str_replace( '---COUNT---',(string) $iMatches,$szXML );
2137 ...         }
2138 ...     }   /* if ( isset( $aHash[$szHash = STR_hash( $szWord = $aMatch['str'] )] ) ) */
2139 ... 
2140 ...     return ( $szXML );
2141 ... }
2142 ... 
2143 ... 
2144 ... function OCRHash( $szStr )
2145 ... /*----------------------*/
2146 ... {
2147 ...     $aWords = mb_split( ' ',$szStr );
2148 ...     $szSeed = '';
2149 ...     $iLimit = 2;
2150 ... 
2151 ...     $iCount = count( $aWords );
2152 ... 
2153 ...     for ( $i = 0; $i < min( $iLimit,$iCount );$i++ )
2154 ...     {
2155 ...         $szSeed .= $aWords[$i] . ' ';
2156 ...     }
2157 ... 
2158 ...     //return ( STR_sort( strtoupper( trim( $szSeed ) ) ) );
2159 ...     return ( strtoupper( trim( $szSeed ) ) );
2160 ... }
2161 ... 
2162 ... function OCRCompile( $szStr )
2163 ... /*-------------------------*/
2164 ... {
2165 ...     $aSubst['a'] = $aSubst['à'] = $aSubst['8'] = $aSubst['g'] = $aSubst['@']                                                                = '1';
2166 ...     $aSubst['c'] = $aSubst['e'] = $aSubst['é'] = $aSubst['Ú'] = $aSubst['o']                                                                = '2';
2167 ...     $aSubst['û'] = $aSubst['0'] = $aSubst['O'] = $aSubst['o'] = $aSubst['C'] = $aSubst['G']                                                 = '3';
2168 ...     $aSubst['B'] = $aSubst['8'] = $aSubst['E'] = $aSubst[chr(128) /* â?¬ */]                                                                  = '4';
2169 ...     $aSubst['Q'] = $aSubst['R']                                                                                                             = '5';
2170 ...     $aSubst['J'] = $aSubst['U'] = $aSubst['u'] = $aSubst['V'] = $aSubst['W'] = $aSubst['v'] = $aSubst['w']                                  = '6';
2171 ...     $aSubst['I'] = $aSubst['T'] = $aSubst['1'] = $aSubst['7'] = $aSubst['l'] = $aSubst['t'] = $aSubst['!'] = $aSubst['i'] = $aSubst['L']    = '7';
2172 ...     $aSubst['H'] = $aSubst['N'] = $aSubst['h'] = $aSubst['n']                                                                               = '8';
2173 ...     $aSubst['S'] = $aSubst['s'] = $aSubst['5'] = $aSubst['$']                                                                               = '9';
2174 ...     $aSubst['D'] = $aSubst['O']                                                                                                             = '0';
2175 ... 
2176 ...     // Here you find corrections to the substitutions (based on what real OCR taught us):
2177 ...     // Such rules supersede the ones set above
2178 ...     $aSubst['L'] = $aSubst['C']; // A C and L are often confused
2179 ... 
2180 ... 
2181 ...     //$szStr = utf8_decode( $szStr );
2182 ... 
2183 ...     //print_r( mb_list_encodings() );
2184 ... 
2185 ...     $szStr = STR_Reduce( mb_convert_encoding( trim( $szStr ),'Windows-1252' ),' ' );
2186 ... 
2187 ...     //print_r( $szStr );
2188 ...     //print_r( ord( $szStr ) );
2189 ...     //print_r( strlen( $szStr ) );
2190 ...     //die();
2191 ...     //var_dump( str_split( $szStr ) );
2192 ... 
2193 ... 
2194 ...     $iLen = strlen( $szStr );
2195 ... 
2196 ...     $szOut = '';
2197 ...     for ( $i = 0; $i < $iLen; $i++ )
2198 ...     {
2199 ...         $c = $szStr[$i];
2200 ... 
2201 ...         if ( isset( $aSubst[$c] ) )
2202 ...         {
2203 ...             $szOut .= $aSubst[$c];
2204 ...         }
2205 ...         else
2206 ...         {
2207 ...             $szOut .= $c;
2208 ...         }
2209 ...     }
2210 ... 
2211 ...     return ( mb_convert_encoding( $szOut,'UTF-8','Windows-1252' ) );
2212 ... }
2213 ... 
2214 ... /* ========================================================================== */
2215 ... /** {{*STR_Soothe( $szStr[,$cChar] )=
2216 ... 
2217 ...     Soothes a string by inserting one character every character
2218 ... 
2219 ...     {*params
2220 ...         $szStr  (string)    The string that must be soothed
2221 ...         $cChar  (char)      The character to "slacken" $szStr with.
2222 ...                             Optional: [c]' '[/c] by default.
2223 ...     *}
2224 ... 
2225 ...     {*return
2226 ...         (string)   $szStr soothed with $cChar
2227 ...     *}
2228 ... 
2229 ...     {*assert
2230 ...         STR_Soothe( 'Hello' ) === 'H e l l o '
2231 ...     *}
2232 ... 
2233 ...     {*example
2234 ...         // If anchor found in User Agent string
2235 ...         if ( preg_match( '%(?P<anchor><a[^>]*>(.*?)</a>)%si',$szUA,$aMatch ) )
2236 ...         {
2237 ...             // This is the anchor that we detected
2238 ...             $szAnchor = $aMatch['anchor'];
2239 ...             // Remove it from the User Agent string (and soothe the anchor)
2240 ...             $szUA     = str_replace( $szAnchor,'',$szUA ) . ' (anchor removed ... ' . STR_Soothe( $szAnchor,'.' ) . ')';
2241 ...             // Echo result
2242 ...             echo "<p>{$szUA}</p>";
2243 ...         }
2244 ...     *}
2245 ...     *}}
2246 ...  */
2247 ... /* ========================================================================== */
2248 ... function STR_Soothe( $szStr,$cChar = ' ' )
2249 ... /*--------------------------------------*/
2250 ... {
2251 ...     $szRetVal   = '';                                               /* Resulting string */
2252 ...     $iLength    = strlen( $szStr );                                 /* Determine length */
2253 ...     for ( $i = 0;$i < $iLength;$i++ )                               /* Treat the entire string (per slice of 8 bits) */
2254 ...     {
2255 ...         $szRetVal .= $szStr[$i] . $cChar;                           /* Concatenate char in string and sooth character */
2256 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
2257 ... 
2258 ...     return ( $szRetVal );                                           /* Return result to caller */
2259 ... }   /* == End of function STR_Soothe() ====================================== */
2260 ... 
2261 ... /* ========================================================================== */
2262 ... /** {{*STR_Ascii( $szStr )=
2263 ... 
2264 ...     Sums ASCII characters of string
2265 ... 
2266 ...     {*params
2267 ...         $szStr  (string)    The string that must be treated
2268 ...     *}
2269 ... 
2270 ...     {*return
2271 ...         (int)   Sum of all ASCII chars; 0 if 0 length string
2272 ...     *}
2273 ... 
2274 ...     {*assert
2275 ...         STR_Ascii( 'A' ) === 65
2276 ...     *}
2277 ... 
2278 ...     {*assert
2279 ...         STR_Ascii( STR_Replicate( 'A',4 ) ) === ( 4 * STR_Ascii( 'A' ) )
2280 ...     *}
2281 ... 
2282 ...     {*assert
2283 ...         STR_Ascii( 'AA' ) === 130
2284 ...     *}
2285 ... 
2286 ...     {*assert
2287 ...         STR_Ascii( 'Ab' ) === STR_Ascii( 'bA' )
2288 ...     *}
2289 ... 
2290 ...     {*seealso
2291 ...         STR_Ascii2()
2292 ...     *}
2293 ... 
2294 ...     {*exec
2295 ...         echo $iSum = STR_Ascii( 'Hello World' );
2296 ...         echo LSUnitTesting::assert( $iSum === 1052                              ,
2297 ...                                     'ASSERTION SUCCESSFUL: correct ASCII value' ,
2298 ...                                     'ASSERTION FAILURE: incorrect ASCII value'  ,
2299 ...                                     'GuideAssert' );
2300 ...     *}
2301 ... 
2302 ...     *}}
2303 ...  */
2304 ... /* ========================================================================== */
2305 ... function STR_Ascii( $szStr )
2306 ... /*------------------------*/
2307 ... {
2308 ...     $iRetVal    = 0;                                                /* Return value of the function */
2309 ...     $iLength = strlen( $szStr );                                    /* Length of the string */
2310 ... 
2311 ...     for ( $i = 0;$i < $iLength;$i++ )                               /* For each character of the string */
2312 ...     {
2313 ...         $iRetVal += ord( $szStr[$i] );                               /* Sum ASCII value */
2314 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
2315 ... 
2316 ...     return ( $iRetVal );                                            /* Return result to caller */
2317 ... }   /* == End of function STR_Ascii() ======================================= */
2318 ... 
2319 ... /* ========================================================================== */
2320 ... /** {{*STR_Ascii2( $szStr )=
2321 ... 
2322 ...     Sums ASCII characters of string (multiplied by position)
2323 ... 
2324 ...     {*params
2325 ...         $szStr  (string)    The string that must be treated
2326 ...     *}
2327 ... 
2328 ...     {*return
2329 ...         (int)   Sum of all ASCII chars (each char is multiplied by its position); 0 if 0 length string
2330 ...     *}
2331 ... 
2332 ...     {*assert
2333 ...         STR_Ascii2( 'Ab' ) !== STR_Ascii2( 'bA' )
2334 ...     *}
2335 ... 
2336 ...     {*assert
2337 ...         STR_Ascii( 'Ab' ) !== STR_Ascii2( 'Ab' )
2338 ...     *}
2339 ... 
2340 ...     {*seealso
2341 ...         STR_Ascii()
2342 ...     *}
2343 ... 
2344 ...     {*exec
2345 ...         echo $iSum = STR_Ascii2( 'Hello World' );
2346 ...         echo LSUnitTesting::assert( $iSum === 5428                                  ,
2347 ...                                     'ASSERTION SUCCESSFUL: correct ASCII 2 value'   ,
2348 ...                                     'ASSERTION FAILURE: incorrect ASCII 2 value'    ,
2349 ...                                     'GuideAssert' );
2350 ...     *}
2351 ... 
2352 ...     *}}
2353 ...  */
2354 ... /* ========================================================================== */
2355 ... function STR_Ascii2( $szStr )
2356 ... /*------------------------*/
2357 ... {
2358 ...     $iRetVal    = 0;                                                /* Return value of the function */
2359 ...     $iLength = strlen( $szStr );                                    /* Length of the string */
2360 ... 
2361 ...     for ( $i = 0;$i < $iLength;$i++ )                               /* For each character of the string */
2362 ...     {
2363 ...         $iRetVal += ( ord( $szStr[$i] ) * $i );                     /* Sum ASCII values */
2364 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
2365 ... 
2366 ...     return ( $iRetVal );                                            /* Return result to caller */
2367 ... }   /* == End of function STR_Ascii2() ====================================== */
2368 ... 
2369 ... /* ========================================================================== */
2370 ... /** {{*STR_shr( $szStr,$nBits )=
2371 ... 
2372 ...     Shifts-Right a string by a given number of [b]bits[/b] ($nBits).
2373 ... 
2374 ...     {*params
2375 ...         $szStr  (string)    The string that must be right shifted
2376 ...         $nBits    (int)       Number of bits to shift the string by.
2377 ...                             Minimum 1 bit, maximum 7 bits.
2378 ...     *}
2379 ... 
2380 ...     {*remark
2381 ...         STR_shr() can be one useful component of an encryption algorithm.
2382 ...     *}
2383 ... 
2384 ...     {*return
2385 ...         (string)   $szStr right-shifted by $nBits
2386 ...     *}
2387 ... 
2388 ...     {*assert
2389 ...         STR_shr( 'C+ccz',3 ) === 'Hello'
2390 ...     *}
2391 ... 
2392 ...     {*seealso
2393 ...         STR_shl()
2394 ...     *}
2395 ... 
2396 ...     {*example
2397 ...         echo '<p>Shifted left: ' . ( $szLShifted = STR_shl( 'Hello',3 ) ) . '</p>'; // Prints 'C+ccz'
2398 ...         echo '<p>Shifted back to right: ' . STR_shr( $szLShifted,3 ) . '</p>';      // Prints 'Hello'
2399 ...     *}
2400 ...     *}}
2401 ...  */
2402 ... /* ========================================================================== */
2403 ... function STR_shr( $szStr,$nBits )
2404 ... /*-----------------------------*/
2405 ... {
2406 ...     if ( $nBits < 1 || $nBits > 7 )                                     /* If not adequate number of bits */
2407 ...     {
2408 ...         return ( $szStr );                                              /* Return the original string */
2409 ...     }   /* if ( $nBits < 1 || $nBits > 7 ) */
2410 ... 
2411 ...     if ( ( $iLength = strlen( $szStr ) ) <= 0 )                         /* If string empty */
2412 ...     {
2413 ...         return ( $szStr );                                              /* Return the original string */
2414 ...     }   /* if ( ( $iLength = strlen( $szStr ) ) <= 0 ) */
2415 ... 
2416 ...     $szRetVal   = '';                                                   /* Create an empty string */
2417 ... 
2418 ...     $szBits     = STR_Binary( $szStr );                                 /* $szStr in bits */
2419 ...     $szLostBits = STR_Right( $szBits,$nBits );                          /* The $nBits rightmost bits of the string */
2420 ...     $szShifted  = $szLostBits . substr( $szBits,0,-$nBits );            /* $szStr right shifted */
2421 ... 
2422 ...     for ( $i = 0;$i < $iLength;$i++ )                                   /* Treat the entire string (per slice of 8 bits) */
2423 ...     {
2424 ...         $szRetVal .= chr( bindec( substr( $szShifted,$i * 8,8 ) ) );    /* Concatenate the CHR to the result string */
2425 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
2426 ... 
2427 ...     return ( $szRetVal );                                               /* Return result to caller */
2428 ... }
2429 ... 
2430 ... //function STR_shr( $szStr,$iBits )
2431 ... ///*------------------------------*/
2432 ... //{
2433 ... //    $iLength  = strlen( $szStr );
2434 ... //    $szResult = $szStr;
2435 ... //
2436 ... //    echo "<p>Chaîne = {$szResult}</p>";
2437 ... //
2438 ... //    if ( ( $iBits > 1 ) && ( $iBits < 7 ) && ( $iLength > 0 ) )
2439 ... //    {
2440 ... //        $lost_bits = (int) ( $szResult[$iLength-1] << (8 - $iBits) );
2441 ... //
2442 ... //        for ( $i=0;$i < $iLength;$i++ )
2443 ... //        {
2444 ... //            $byte           = (int) $szResult[$i];
2445 ... //            $szResult[$i] = $szResult[$i] >> $iBits;
2446 ... //            $szResult[$i]  = ( (int) $szResult[$i] + $lost_bits );
2447 ... //            //$lost_bits      = $byte << (8 - $iBits);
2448 ... //        }
2449 ... //    }
2450 ... //
2451 ... //    if ( is_array( $szResult ) )
2452 ... //    {
2453 ... //        $szResult = implode( '',$szResult );
2454 ... //    }
2455 ... //
2456 ... //    return ( $szResult );
2457 ... //}
2458 ... ///* ====================================================================== */
2459 ... 
2460 ... /* ========================================================================== */
2461 ... /** {{*STR_Binary( $szStr )=
2462 ... 
2463 ...     Returns a binary representation of $szStr (bit by bit)
2464 ... 
2465 ...     {*params
2466 ...         $szStr  (string)    The string that must be turned to a binary
2467 ...                             representation. A single letter is represented by
2468 ...                             a string of 8 chars (A is for example turned to its
2469 ...                             binary representation as [c]'01000001'[/c]).
2470 ...     *}
2471 ... 
2472 ...     {*return
2473 ...         (string)   Binary representation of $szStr
2474 ...     *}
2475 ... 
2476 ...     {*seealso
2477 ...         STR_shl(), STR_shr()
2478 ...     *}
2479 ... 
2480 ...     {*assert STR_Binary( 'A' ) === '01000001' *}
2481 ...     {*assert STR_Binary( 'B' ) === '01000010' *}
2482 ...     {*assert STR_Binary( 'AB' ) === '0100000101000010' *}
2483 ...     {*assert count( STR_Carve( STR_Binary( $szStr = 'Hello World' ),8 ) ) === strlen( $szStr ) *}
2484 ... 
2485 ...     {*exec
2486 ...         $szBits = STR_Binary( 'A' );
2487 ...         echo '<p>',$szBits,'</p>';
2488 ... 
2489 ...         $szBits = STR_Binary( 'B' );
2490 ...         echo '<p>',$szBits,'</p>';
2491 ... 
2492 ...         $szBits = STR_Binary( 'Hello World' );
2493 ...         echo '<p>',$szBits,'</p>';
2494 ...     *}
2495 ... 
2496 ...     {*seealso
2497 ...         STR_Yranib()
2498 ...     *}
2499 ... 
2500 ...     *}}
2501 ...  */
2502 ... /* ========================================================================== */
2503 ... function STR_Binary( $szStr )
2504 ... /*-------------------------*/
2505 ... {
2506 ...     $szRetVal = '';                                                 /* Ready to return an empty string */
2507 ... 
2508 ...     if ( ( $iLength = strlen( $szStr ) ) > 0 )                      /* If string NOT empty */
2509 ...     {
2510 ...         for ( $i = 0; $i < $iLength;$i++ )                          /* Treat each character of the string */
2511 ...         {
2512 ...             $szRetVal .= sprintf( '%08b',ord( $szStr[$i] ) );       /* Turn this char to a binary representation (8 bits) */
2513 ...         }   /* for ( $i = 0; $i < $iLength;$i++ ) */
2514 ...     }   /* if ( ( $iLength = strlen( $szStr ) ) > 0 ) */
2515 ... 
2516 ...     return ( $szRetVal );                                           /* Return result to caller */
2517 ... }   /* == End of function STR_Binary() =====================================  */
2518 ... 
2519 ... /* ========================================================================== */
2520 ... /** {{*STR_Yranib( $szStr )=
2521 ... 
2522 ...     Reverse function of [c]STR_Binary()[/c]
2523 ... 
2524 ...     {*params
2525 ...         $szStr  (string)    A string that has previously been processed by
2526 ...                             [c]STR_Binary()[/c]
2527 ...     *}
2528 ... 
2529 ...     {*return
2530 ...         (string)   Reversed string
2531 ...     *}
2532 ... 
2533 ...     {*assert STR_Yranib( STR_Binary( 'My good friend' ) ) === 'My good friend' *}
2534 ... 
2535 ...     {*exec
2536 ...         $szBin      = STR_Binary( 'Hello World' );
2537 ...         echo '<p>',$szBin,'</p>';
2538 ... 
2539 ...         $szUnBin    = STR_Yranib( $szBin );
2540 ...         echo '<p>',$szUnBin,'</p>';
2541 ... 
2542 ...         echo LSUnitTesting::assert( $szUnBin === 'Hello World'                              ,
2543 ...                                     'ASSERTION SUCCESSFUL: string successfully recovered'   ,
2544 ...                                     'ASSERTION FAILURE: string recovery falure'             ,
2545 ...                                     'GuideAssert' );
2546 ...     *}
2547 ... 
2548 ...     {*author  *}
2549 ...     {*version 6.0.0006 *}
2550 ...     {*cdate 22/04/2014 19:45 *}
2551 ... 
2552 ...     {*seealso
2553 ...         STR_Binary()
2554 ...     *}
2555 ... 
2556 ...     *}}
2557 ...  */
2558 ... /* ========================================================================== */
2559 ... function STR_Yranib( $szStr )
2560 ... /*-------------------------*/
2561 ... {
2562 ...     $szRetVal   = '';
2563 ...     $aStrs      = STR_Carve( $szStr,8 );
2564 ... 
2565 ...     foreach( $aStrs as $szChar )
2566 ...     {
2567 ...         if ( strlen( $szChar ) === 8 )
2568 ...         {
2569 ...             $aChars = str_split( $szChar,1 );
2570 ...             $iValue = 0;
2571 ... 
2572 ...             for( $i=7;$i>=0;$i-- )
2573 ...             {
2574 ...                 $iValue += $aChars[$i] == '1' ? pow( 2,7 - $i ) : 0;
2575 ...             }
2576 ... 
2577 ...             $szRetVal .= chr( $iValue );
2578 ...         }
2579 ...     }
2580 ... 
2581 ...     return ( $szRetVal );
2582 ... }
2583 ... 
2584 ... function STR_Substitute( $szToReplace,$szReplacement,$szStr )
2585 ... /*---------------------------------------------------------*/
2586 ... {
2587 ...     return ( str_ireplace( str_split( $szToReplace ),               /* Turn all chars to an array */
2588 ...                            $szReplacement           ,               /* All chars must be replaced with szReplacement */
2589 ...                            $szStr ) );                              /* Return result to caller */
2590 ... }
2591 ... 
2592 ... /* ========================================================================== */
2593 ... /** {{*STR_Tao( $szStr )=
2594 ... 
2595 ...     Simply returns what was given as input
2596 ... 
2597 ...     {*params
2598 ...         $szStr      (string)    Input string
2599 ...     *}
2600 ... 
2601 ...     {*remark
2602 ...         TAO functions do return what they were given
2603 ...     *}
2604 ... 
2605 ...     {*return
2606 ...         (string)        $szStr
2607 ...     *}
2608 ... 
2609 ...     {*assert
2610 ...         STR_Tao( 'Hello World' ) === 'Hello World'
2611 ...     *}
2612 ... 
2613 ...     {*assert
2614 ...         STR_Tao( 1 ) === '1'
2615 ...     *}
2616 ... 
2617 ...     {*assert
2618 ...         STR_Tao( null ) === ''
2619 ...     *}
2620 ... 
2621 ...     {*assert
2622 ...         STR_Tao( true ) === 'true'
2623 ...     *}
2624 ... 
2625 ...     {*assert
2626 ...         STR_Tao( false ) === 'false'
2627 ...     *}
2628 ... 
2629 ...     *}}
2630 ...  */
2631 ... /* ========================================================================== */
2632 ... function STR_Tao( $szStr )
2633 ... /*----------------------*/
2634 ... {
2635 ...     return ( STR_Make( $szStr ) );
2636 ... }   /* == End of function STR_Tao() ========================================  */
2637 ... 
2638 ... /* ========================================================================== */
2639 ... /** {{*STR_Null( $x )=
2640 ... 
2641 ...     Returns a [c]null[/c] (ALWAYS)
2642 ... 
2643 ...     {*params
2644 ...         $x      (mixed) Whatever is sent
2645 ...     *}
2646 ... 
2647 ...     {*remark
2648 ...         This function can be used with nested functions to get rid of a return value.
2649 ...         See also [c]MISC_true()[/c] and [c]MISC_false()[/c].
2650 ...     *}
2651 ... 
2652 ...     {*return
2653 ...         (null)  always [c]null[/c]
2654 ...     *}
2655 ... 
2656 ...     {*assert is_null( STR_Null( 1878 ) ) *}
2657 ... 
2658 ...     {*exec
2659 ...         if ( is_null( STR_Null( 'Hello World' ) ) )
2660 ...         {
2661 ...             echo "Got a null";
2662 ...         }
2663 ...     *}
2664 ... 
2665 ...     {*seealso
2666 ...         STR_Tao()
2667 ...     *}
2668 ... 
2669 ...     *}}
2670 ...  */
2671 ... /* ========================================================================== */
2672 ... function STR_Null( $x )
2673 ... /*-------------------*/
2674 ... {
2675 ...     return ( null );
2676 ... }   /* == End of function STR_Null() =======================================  */
2677 ... 
2678 ... /* ========================================================================== */
2679 ... /** {{*STR_asc( $c )=
2680 ... 
2681 ...     Returns the ASCII value of the $c character
2682 ... 
2683 ...     {*params
2684 ...         $c  (char)  The character whose ASCII value must be returned
2685 ...     *}
2686 ... 
2687 ...     {*alias
2688 ...         asc()
2689 ...     *}
2690 ... 
2691 ...     {*remark
2692 ...         This function is more to be used under its alias form: [c]asc()[/c].
2693 ...         It uses the [c]ord()[/c] PHP built-in function
2694 ...     *}
2695 ... 
2696 ...     {*return
2697 ...         (int)   Returns the ASCII value of $c as an integer
2698 ...     *}
2699 ... 
2700 ...     {*assert
2701 ...         STR_Asc( 'A' ) === 65
2702 ...     *}
2703 ... 
2704 ...     {*assert
2705 ...         STR_Asc( 'AB' ) === 65
2706 ...     *}
2707 ... 
2708 ...     {*assert
2709 ...         STR_Asc( 'B' ) === 66
2710 ...     *}
2711 ... 
2712 ...     {*assert
2713 ...         STR_Asc( ' ' ) === 32
2714 ...     *}
2715 ... 
2716 ...     *}}
2717 ...  */
2718 ... /* ========================================================================== */
2719 ... function STR_asc( $c )
2720 ... /*------------------*/
2721 ... {
2722 ...     return ( ord( $c ) );
2723 ... }
2724 ... function asc( $c ) { return ord( $c ); }
2725 ... /* == End of function STR_asc()=============================================  */
2726 ... 
2727 ... 
2728 ... //STR_IsInSet() : Determines if characters of the specified string belongs to a set of characters.
2729 ... //Alias
2730 ... //IsInSet(), InSet()
2731 ... //Syntax
2732 ... //STR_IsInSet( szString,szCharacters[,nStart[,nLength]] ) ? lResult
2733 ... //Parameters
2734 ... //szString    string to process.
2735 ... //szCharacters    characters that must be taken in account.
2736 ... //nStart    specifies the position in the character string from where the string is going to be processed. Optional. When not mentioned, the string is processed from the first position.
2737 ... //nLength    specifies the number of characters to process. Optional. When not mentioned, the string is processed from the starting position to the end of the string.
2738 ... //Returns
2739 ... //lResult    are all the examined characters belonging to the cCharacters set of characters? [c]true[/c] if yes, [c]false[/c] if not.
2740 ... //Example
2741 ... //? STR_IsInSet( " â??123.18"," +-0123456789." )   && [c]true[/c]
2742 ... //See also
2743 ... //STR_IsUpper(), STR_IsCharLower(), STR_IsCharUpper(), STR_IsCharAlpha(), STR_IsCharAlphaNumeric(), STR_IsCharPunct(), STR_IsCharSpace(), STR_IsCharPrint(), STR_IsCharGraph().
2744 ... 
2745 ... 
2746 ... /* ========================================================================== */
2747 ... /** {{*STR_stripAccents( $szStr )=
2748 ... 
2749 ...     Removes all accents from a string (WordPress implementation)
2750 ... 
2751 ...     {*params
2752 ...         $szStr   (string)   Input string
2753 ...     *}
2754 ... 
2755 ...     {*return
2756 ...         (string)    All accents remived from $szStr
2757 ...     *}
2758 ... 
2759 ...     {*assert
2760 ...         STR_aeiouy( '� demain, ce sera un bel été' ) === 'a demain, ce sera un bel ete'
2761 ...     *}
2762 ...     *}}
2763 ...  */
2764 ... /* ========================================================================== */
2765 ... function STR_stripAccents( $szStr )
2766 ... /*-------------------------------*/
2767 ... {
2768 ...     if ( ! preg_match('/[\x80-\xff]/',$szStr ) )
2769 ...     {
2770 ...         return ( $szStr );
2771 ...     }
2772 ... 
2773 ...     $chars = array(
2774 ...     // Decompositions for Latin-1 Supplement
2775 ...     chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
2776 ...     chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
2777 ...     chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
2778 ...     chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
2779 ...     chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
2780 ...     chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
2781 ...     chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
2782 ...     chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
2783 ...     chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
2784 ...     chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
2785 ...     chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
2786 ...     chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
2787 ...     chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
2788 ...     chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
2789 ...     chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
2790 ...     chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
2791 ...     chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
2792 ...     chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
2793 ...     chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
2794 ...     chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
2795 ...     chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
2796 ...     chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
2797 ...     chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
2798 ...     chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
2799 ...     chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
2800 ...     chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
2801 ...     chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
2802 ...     chr(195).chr(191) => 'y',
2803 ...     // Decompositions for Latin Extended-A
2804 ...     chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
2805 ...     chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
2806 ...     chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
2807 ...     chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
2808 ...     chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
2809 ...     chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
2810 ...     chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
2811 ...     chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
2812 ...     chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
2813 ...     chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
2814 ...     chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
2815 ...     chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
2816 ...     chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
2817 ...     chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
2818 ...     chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
2819 ...     chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
2820 ...     chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
2821 ...     chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
2822 ...     chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
2823 ...     chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
2824 ...     chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
2825 ...     chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
2826 ...     chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
2827 ...     chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
2828 ...     chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
2829 ...     chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
2830 ...     chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
2831 ...     chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
2832 ...     chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
2833 ...     chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
2834 ...     chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
2835 ...     chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
2836 ...     chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
2837 ...     chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
2838 ...     chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
2839 ...     chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
2840 ...     chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
2841 ...     chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
2842 ...     chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
2843 ...     chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
2844 ...     chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
2845 ...     chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
2846 ...     chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
2847 ...     chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
2848 ...     chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
2849 ...     chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
2850 ...     chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
2851 ...     chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
2852 ...     chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
2853 ...     chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
2854 ...     chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
2855 ...     chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
2856 ...     chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
2857 ...     chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
2858 ...     chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
2859 ...     chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
2860 ...     chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
2861 ...     chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
2862 ...     chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
2863 ...     chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
2864 ...     chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
2865 ...     chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
2866 ...     chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
2867 ...     chr(197).chr(190) => 'z', chr(197).chr(191) => 's' );
2868 ... 
2869 ...     return ( strtr( $szStr,$chars ) );
2870 ... }   /* End of function STR_stripAccents() =================================== */
2871 ... 
2872 ... /* ========================================================================== */
2873 ... /** {{*STR_aeiouy( $szStr )=
2874 ... 
2875 ...     Transforms 'a','e','i','o',u','y' entities and variations
2876 ...     (uppercase and lowercase) into their respective equivalents
2877 ... 
2878 ...     {*params
2879 ...         $szStr   (string)   Input string
2880 ...     *}
2881 ... 
2882 ...     {*return
2883 ...         (string)    All variations (uppercase and lowercase) turned
2884 ...                     to their equivalents
2885 ...     *}
2886 ... 
2887 ...     {*assert
2888 ...         STR_aeiouy( 'Ã? demain, ce sera un bel &eacute;t&eacute;' ) === 'a demain, ce sera un bel ete'
2889 ...     *}
2890 ...     *}}
2891 ...  */
2892 ... /* ========================================================================== */
2893 ... function STR_aeiouy( $szStr )
2894 ... /*------------------------*/
2895 ... {
2896 ...     return ( STR_y2( STR_y(
2897 ...              STR_u2( STR_u(
2898 ...              STR_o2( STR_o(
2899 ...              STR_i2( STR_i(
2900 ...              STR_e2( STR_e(
2901 ...              STR_a2( STR_a( $szStr ) ) ) ) ) ) ) ) ) ) ) ) );
2902 ... }   /* End of function STR_aeiouy() ========================================= */
2903 ... 
2904 ... /* ========================================================================== */
2905 ... /** {{*STR_a( $szStr )=
2906 ... 
2907 ...     Transforms 'a' variations  (uppercase and lowercase) into 'a' equivalent
2908 ... 
2909 ...     {*params
2910 ... 
2911 ...     $szStr   (string)   Input string
2912 ...     *}
2913 ... 
2914 ...     {*return
2915 ... 
2916 ...      (string)           All 'a' variations (uppercase and lowercase) turned to 'a'
2917 ...     *}
2918 ... 
2919 ...     {*assert
2920 ...         STR_a( 'Ã? demain' ) === 'a demain'
2921 ...     *}
2922 ... 
2923 ...     {*seealso
2924 ...         STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_u(), STR_u2(), STR_y(), STR_y2()
2925 ...     *}
2926 ...     *}}
2927 ...  */
2928 ... /* ====================================================================== */
2929 ... function STR_a( $szStr )
2930 ... /*--------------------*/
2931 ... {
2932 ...     return ( STR_Substitute( 'àáâãÀåÊ','a',$szStr ) );
2933 ... }   /* == End of function STR_a() ======================================  */
2934 ... 
2935 ... /* ====================================================================== */
2936 ... /** {{*STR_a2( $szStr )=
2937 ... 
2938 ...     Transforms [c]'a'[/c] entities (uppercase and lowercase) into
2939 ...     [c]'a'[/c] equivalent
2940 ... 
2941 ...     {*params
2942 ...         $szStr   (string)   Input string
2943 ...     *}
2944 ... 
2945 ...     {*return
2946 ... 
2947 ...      (string)           All [c]'a'[/c] entities (uppercase and lowercase)
2948 ...                         turned to [c]'a'[/c]
2949 ...     *}
2950 ... 
2951 ...     {*assert
2952 ...         STR_a2( '&Agrave; demain' ) === 'a demain' // chr(65) + 'Agrave'
2953 ...     *}
2954 ... 
2955 ...     {*seealso
2956 ...         STR_a(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_u(), STR_u2(), STR_y(), STR_y2()
2957 ...     *}
2958 ...     *}}
2959 ...  */
2960 ... /* ====================================================================== */
2961 ... function STR_a2( $szStr )
2962 ... /*---------------------*/
2963 ... {
2964 ...     //var_dump(explode( '-','&aacute;-&agrave;-&acirc;-&auml;-&aelig;-&aring;-&atilde;' ));
2965 ...     return ( str_ireplace( explode( '-','&aacute;-&agrave;-&acirc;-&auml;-&aelig;-&aring;-&atilde;' ),'a',$szStr ) );
2966 ... }   /* == End of function STR_a2() =====================================  */
2967 ... 
2968 ... /* ====================================================================== */
2969 ... /** {{*STR_e( $szStr )=
2970 ... 
2971 ...     Transforms 'e' variations (uppercase and lowercase) into 'e' equivalent
2972 ... 
2973 ...     {*params
2974 ... 
2975 ...     $szStr   (string)   Input string
2976 ...     *}
2977 ... 
2978 ...     {*return
2979 ...      (string)           All 'e' variations (uppercase and lowercase) turned to 'e'
2980 ...     *}
2981 ... 
2982 ...     {*example
2983 ...      echo STR_e( "C'est l'été. T'es prêt ?" );    // Prints "C'est l'ete. T'es pret ?"
2984 ...     *}
2985 ...     *}}
2986 ...  */
2987 ... /* ====================================================================== */
2988 ... function STR_e( $szStr )
2989 ... /*--------------------*/
2990 ... {
2991 ...     return ( STR_Substitute( 'Úéêë','e',$szStr ) );
2992 ... }   /* == End of function STR_e() ======================================  */
2993 ... 
2994 ... /* ====================================================================== */
2995 ... /** {{*STR_e2( $szStr )=
2996 ... 
2997 ...     Transforms 'e' entities (uppercase and lowercase) into 'e' equivalent
2998 ... 
2999 ...     {*params
3000 ... 
3001 ...     $szStr   (string)   Input string
3002 ...     *}
3003 ... 
3004 ...     {*return
3005 ...      (string)           All 'e' entities (uppercase and lowercase) turned to 'e'
3006 ...     *}
3007 ... 
3008 ...     {*example
3009 ...      echo STR_e2( "C'est l'&eacute;t&eacute;" );    // Prints "C'est l'ete"
3010 ...     *}
3011 ...     *}}
3012 ...  */
3013 ... /* ====================================================================== */
3014 ... function STR_e2( $szStr )
3015 ... /*---------------------*/
3016 ... {
3017 ...     //echo "On me demande un e2()";
3018 ...     $d = str_ireplace( explode( '-','&eacute;-&egrave;-&ecirc;-&euml;-&eelig;-&ering;-&etilde;' ),'e',$szStr );
3019 ...     //echo "AprÚs e2<br>",$d;
3020 ...     return ( str_ireplace( explode( '-','&eacute;-&egrave;-&ecirc;-&euml;-&eelig;-&ering;-&etilde;' ),'e',$szStr ) );
3021 ... }   /* == End of function STR_e2() =====================================  */
3022 ... 
3023 ... /* ====================================================================== */
3024 ... /** {{*STR_i( $szStr )=
3025 ... 
3026 ...     Transforms 'i' variations (uppercase and lowercase) into 'i' equivalent
3027 ... 
3028 ...     {*params
3029 ...         $szStr   (string)   Input string
3030 ...     *}
3031 ... 
3032 ...     {*return
3033 ...         (string)           All 'i' variations (ìíîï) (uppercase and lowercase) turned to 'i'
3034 ...     *}
3035 ... 
3036 ...     {*example
3037 ...         echo STR_i( "C'est une belle île" );    // Prints "C'est une belle ile"
3038 ...     *}
3039 ...     *}}
3040 ...  */
3041 ... /* ====================================================================== */
3042 ... function STR_i( $szStr )
3043 ... /*--------------------*/
3044 ... {
3045 ...     return ( STR_Substitute( 'ìíîï','i',$szStr ) );
3046 ... }   /* == End of function STR_i() ======================================  */
3047 ... 
3048 ... /* ====================================================================== */
3049 ... /** {{*STR_i2( $szStr )=
3050 ... 
3051 ...     Transforms 'i' entities (uppercase and lowercase) into 'i' equivalent
3052 ... 
3053 ...     {*params
3054 ...         $szStr   (string)   Input string
3055 ...     *}
3056 ... 
3057 ...     {*return
3058 ...         (string)    All 'i' entities (uppercase and lowercase) turned to 'i'
3059 ...     *}
3060 ... 
3061 ...     {*example
3062 ...      echo STR_i2( "C'est une belle &icirc;le" );    // Prints "C'est une belle ile"
3063 ...     *}
3064 ...     *}}
3065 ...  */
3066 ... /* ========================================================================== */
3067 ... function STR_i2( $szStr )
3068 ... /*---------------------*/
3069 ... {
3070 ...     return ( str_ireplace( explode( '-','&igrave;-&iacute;-&icirc;-&iuml;' ),'i',$szStr ) );
3071 ... }   /* == End of function STR_i2() =========================================  */
3072 ... 
3073 ... function STR_EntityNumbers( $szStr,$bReverse = false )
3074 ... /*--------------------------------------------------*/
3075 ... {
3076 ...     $aFrom = array( 'à','á','â','À'                     ,   /* 01 */
3077 ...                     'é','Ú','ê','ë'                     ,   /* 02 */
3078 ...                     'í','ì','î','ï'                     ,   /* 03 */
3079 ...                     'ó','ò','�','ö'                     ,   /* 04 */
3080 ...                     'ú','ù','û','Ì'                     ,   /* 05 */
3081 ...                     'Ü','Ü','ÿ'                         ,   /* 06 */
3082 ...                     'ç'                                 ,   /* 07 */
3083 ...                                                             /* 08 */
3084 ...                     'Ã?','Ã?','Ã?','Ã?'                     ,   /* 09 */
3085 ...                     'Ã?','Ã?','Ã?','Ã?'                     ,   /* 10 */
3086 ...                     'Ã?','Ã?','Ã?','Ã?'                     ,   /* 11 */
3087 ...                     'Ã?','Ã?','Ã?','Ã?'                     ,   /* 12 */
3088 ...                     'Ã?','Ã?','Ã?','Ã?'                     ,   /* 13 */
3089 ...                     'Ã?','Ã?','Å?'                         ,   /* 14 */
3090 ...                     'Ã?'                                 ,   /* 15 */
3091 ...                                                             /* 16 */
3092 ...                     'Å?'                                 ,   /* 17 */
3093 ...                     'Ê'                                 ,   /* 18 */
3094 ...                     'Å?'                                 ,   /* 19 */
3095 ...                     'Ã?'                                 ,   /* 20 */
3096 ...                     '«'                                 ,   /* 21 */
3097 ...                     '»'                                 ,   /* 22 */
3098 ...                     'â??'                                 ,   /* 23 */
3099 ...                     'â??'                                 ,   /* 24 */
3100 ...                     'â??'                                 ,   /* 25 */
3101 ...                     'â??'                                 ,   /* 26 */
3102 ...                     '°'                                 ,   /* 27 */
3103 ...                     'Œ'                                 ,   /* 28 */
3104 ...                     'œ'                                 ,   /* 29 */
3105 ...                     'Ÿ'                                 ,   /* 30 */
3106 ...                     'â?Š'                                 ,   /* 31 */
3107 ...                     '©'                                 ,   /* 32 */
3108 ...                     '®'                                 ,   /* 33 */
3109 ...                     'â?¢'                                     /* 34 */
3110 ...                   );
3111 ... 
3112 ...     $aTo = array( '&#224;','&#225;','&#226;','&#228;'   ,   /* 01 */
3113 ...                   '&#233;','&#232;','&#234;','&#235;'   ,   /* 02 */
3114 ...                   '&#237;','&#236;','&#238;','&#239;'   ,   /* 03 */
3115 ...                   '&#243;','&#242;','&#244;','&#246;'   ,   /* 04 */
3116 ...                   '&#250;','&#249;','&#251;','&#252;'   ,   /* 05 */
3117 ...                   '&#253;','&#253;','&#255;'            ,   /* 06 */
3118 ...                   '&#231;'                              ,   /* 07 */
3119 ...                                                             /* 08 */
3120 ...                   '&#192;','&#193;','&#194;','&#196;'   ,   /* 09 */
3121 ...                   '&#201;','&#200;','&#202;','&#203;'   ,   /* 10 */
3122 ...                   '&#205;','&#204;','&#206;','&#207;'   ,   /* 11 */
3123 ...                   '&#211;','&#210;','&#212;','&#214;'   ,   /* 12 */
3124 ...                   '&#218;','&#217;','&#219;','&#220;'   ,   /* 13 */
3125 ...                   '&#221;','&#221;','Å?'                 ,   /* 14 */
3126 ...                   '&#199;'                              ,   /* 15 */
3127 ...                                                             /* 16 */
3128 ...                   '&#339;'                              ,   /* 17 */
3129 ...                   '&#230;'                              ,   /* 18 */
3130 ...                   '&#338;'                              ,   /* 19 */
3131 ...                   '&#198;'                              ,   /* 20 */
3132 ...                   '&#171;'                              ,   /* 21 */
3133 ...                   '&#187;'                              ,   /* 22 */
3134 ...                   '&#8216;'                             ,   /* 23 */
3135 ...                   '&#8217;'                             ,   /* 24 */
3136 ...                   '&#8220;'                             ,   /* 25 */
3137 ...                   '&#8221;'                             ,   /* 26 */
3138 ...                   '&#176;'                              ,   /* 27 */
3139 ...                   '&#188;'                              ,   /* 28 */
3140 ...                   '&#189;'                              ,   /* 29 */
3141 ...                   '&#190;'                              ,   /* 30 */
3142 ...                   '&#8230;'                             ,   /* 31 */
3143 ...                   '&#169;'                              ,   /* 32 */
3144 ...                   '&#174;'                              ,   /* 33 */
3145 ...                   '&#8482;'                                 /* 34 */
3146 ...                 );
3147 ... 
3148 ...     return ( str_replace( ( $bReverse ? $aTo   : $aFrom ),
3149 ...                           ( $bReverse ? $aFrom : $aTo   ),
3150 ...                           $szStr ) );
3151 ... }
3152 ... 
3153 ... /* ========================================================================== */
3154 ... /** {{*STR_o( $szStr )=
3155 ... 
3156 ...     Transforms 'o' variations (uppercase and lowercase) into 'o' equivalent
3157 ... 
3158 ...     {*params
3159 ...         $szStr   (string)   Input string
3160 ...     *}
3161 ... 
3162 ...     {*return
3163 ...         (string)    All 'o' variations (�òó�õö) (uppercase and lowercase) turned to 'o'
3164 ...     *}
3165 ... 
3166 ...     {*example
3167 ...         echo STR_o( "Ã?, que c'est drÃ?le!" );    // Prints "o, que c'est drole!"
3168 ...     *}
3169 ...     *}}
3170 ...  */
3171 ... /* ========================================================================== */
3172 ... function STR_o( $szStr )
3173 ... /*--------------------*/
3174 ... {
3175 ...     return ( STR_Substitute( '�òó�õö','o',$szStr ) );
3176 ... }   /* == End of function STR_o() =========================================== */
3177 ... 
3178 ... /* ========================================================================== */
3179 ... /** {{*STR_o2( $szStr )=
3180 ... 
3181 ...     Transforms 'o' entities (uppercase and lowercase) into 'o' equivalent
3182 ... 
3183 ...     {*params
3184 ...         $szStr   (string)   Input string
3185 ...     *}
3186 ... 
3187 ...     {*return
3188 ...         (string)    All 'o' entities (uppercase and lowercase) turned to 'o'
3189 ...     *}
3190 ... 
3191 ...     {*example
3192 ...         echo STR_o2( "&Ocirc;, que c'est dr&ocirc;le!" );    // Prints "o, que c'est drole!"
3193 ...     *}
3194 ...     *}}
3195 ...  */
3196 ... /* ========================================================================== */
3197 ... function STR_o2( $szStr )
3198 ... /*---------------------*/
3199 ... {
3200 ...     return ( str_ireplace( explode( '-','&Oslash;-&ograve;-&oacute;-&ocirc;-&otilde;-&ouml;' ),'o',$szStr ) );
3201 ... }   /* == End of function STR_o2() =========================================  */
3202 ... 
3203 ... /* ========================================================================== */
3204 ... /** {{*STR_u( $szStr )=
3205 ... 
3206 ...     Transforms 'u' variations  (uppercase and lowercase) into 'u' equivalent
3207 ... 
3208 ...     {*params
3209 ...         $szStr   (string)   Input string
3210 ...     *}
3211 ... 
3212 ...     {*return
3213 ...         (string)            All 'u' variations (ùúûÌ) (uppercase and lowercase) turned to 'u'
3214 ...     *}
3215 ... 
3216 ...     {*example
3217 ...         echo STR_u( 'Où êtes-vous?' );    // Prints 'ou êtes-vous?'
3218 ...     *}
3219 ... 
3220 ...     {*seealso
3221 ...         STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_a(), STR_u2(), STR_y(), STR_y2()
3222 ...     *}
3223 ...     *}}
3224 ...  */
3225 ... /* ========================================================================== */
3226 ... function STR_u( $szStr )
3227 ... /*--------------------*/
3228 ... {
3229 ...     return ( STR_Substitute( 'ùúûÌ','u',$szStr ) );
3230 ... }   /* == End of function STR_u() ==========================================  */
3231 ... 
3232 ... /* ========================================================================== */
3233 ... /** {{*STR_u2( $szStr )=
3234 ... 
3235 ...     Transforms 'u' entities (uppercase and lowercase) into 'u' equivalent
3236 ... 
3237 ...     {*params
3238 ...         $szStr   (string)   Input string
3239 ...     *}
3240 ... 
3241 ...     {*return
3242 ...         (string)    All 'u' entities (&ugrave; &uacute; &ucirc; &uuml;)
3243 ...                     (uppercase and lowercase) turned to 'u'
3244 ...     *}
3245 ... 
3246 ...     {*example
3247 ...         echo STR_u2( "C'est o&ugrave; le mois d'ao&ucirc;t ?" );    // Prints "C'est ou le mois d'aout ?"
3248 ...     *}
3249 ... 
3250 ...     {*seealso
3251 ...         STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_a(), STR_u(), STR_y(), STR_y2()
3252 ...     *}
3253 ...     *}}
3254 ...  */
3255 ... /* ====================================================================== */
3256 ... function STR_u2( $szStr )
3257 ... /*---------------------*/
3258 ... {
3259 ...     return ( str_ireplace( explode( '-','&ugrave;-&uacute;-&ucirc;-&uuml;' ),'u',$szStr ) );
3260 ... }   /* == End of function STR_u2() ====================================== */
3261 ... 
3262 ... /* ====================================================================== */
3263 ... /** {{*STR_y( $szStr )=
3264 ... 
3265 ...     Transforms 'y' variations  (uppercase and lowercase) into 'y' equivalent
3266 ... 
3267 ...     {*params
3268 ...         $szStr   (string)   Input string
3269 ...     *}
3270 ... 
3271 ...     {*return
3272 ...         (string All 'y' variations (uppercase and lowercase) turned to 'y'
3273 ...     *}
3274 ... 
3275 ...     {*example
3276 ...         echo STR_y( 'Ãœell' );    // Prints 'yell'
3277 ...     *}
3278 ... 
3279 ...     {*seealso
3280 ...         STR_y2(), STR_a(), STR_a2(), STR_e(), STR_e2()
3281 ...     *}
3282 ... 
3283 ...     *}}
3284 ...  */
3285 ... /* ====================================================================== */
3286 ... function STR_y( $szStr )
3287 ... /*--------------------*/
3288 ... {
3289 ...     return ( STR_Substitute( 'ÿÜ','y',$szStr ) );
3290 ... }   /* == End of function STR_y() ======================================= */
3291 ... 
3292 ... /* ====================================================================== */
3293 ... /** {{*STR_y2( $szStr )=
3294 ... 
3295 ...     Transforms 'y' entities (uppercase and lowercase) into 'y' equivalent
3296 ... 
3297 ...     {*params
3298 ...         $szStr   (string)   Input string
3299 ...     *}
3300 ... 
3301 ...     {*return
3302 ...         (string)    All 'y' entities (uppercase and lowercase) turned to 'y'
3303 ...     *}
3304 ... 
3305 ...     {*example
3306 ...         echo STR_y2( '&yacute;ell' );    // Prints 'yell'
3307 ...     *}
3308 ... 
3309 ...     {*seealso
3310 ...         STR_y(), STR_a(), STR_a2(), STR_e(), STR_e2()
3311 ...     *}
3312 ... 
3313 ...     *}}
3314 ...  */
3315 ... /* ====================================================================== */
3316 ... function STR_y2( $szStr )
3317 ... /*---------------------*/
3318 ... {
3319 ...     return ( str_ireplace( explode( '-','&yuml;-&yacute;' ),'u',$szStr ) );
3320 ... }   /* == End of function STR_y2() ====================================== */
3321 ... 
3322 ... /* ====================================================================== */
3323 ... /** {{*STR_Between( $szStr,$szStart,$szStop,$bType )=
3324 ... 
3325 ...     Returns the portion of a string that falls between two delineators,
3326 ...     exclusive or inclusive of the delineators
3327 ... 
3328 ...     {*params
3329 ...         $szStr   (string)   Input string to parse
3330 ...         $szStart (string)   Defines the beginning of the sub string
3331 ...         $szStop  (string)   Defines the end of the sub string
3332 ...         $bType   (bool)     INCL: include delineators in parsed string[br]
3333 ...                             EXCL: exclude delineators in parsed string
3334 ...     *}
3335 ... 
3336 ...     {*return
3337 ...         (string)   What is between $szStart and $szStop or [c]null[/c] if not found
3338 ...     *}
3339 ... 
3340 ...     {*assert
3341 ...         STR_Between( 'The big house is blue','big','is',EXCL ) === ' house '
3342 ...     *}
3343 ...     *}}
3344 ...  */
3345 ... /* ====================================================================== */
3346 ... function STR_Between( $szStr,$szStart,$szStop,$bType )
3347 ... /*--------------------------------------------------*/
3348 ... {
3349 ...     return ( return_between( $szStr,$szStart,$szStop,$bType ) );
3350 ... }   /* == End of function STR_Between() ===================================== */
3351 ... 
3352 ... /* ========================================================================== */
3353 ... /** {{*STR_aBetween( $szStr,$szStart,$szStop )=
3354 ... 
3355 ...     Returns an array of string matches that fall between two delineators
3356 ... 
3357 ...     {*params
3358 ...         $szStr   (string)   Input string to parse
3359 ...         $szStart (string)   Defines the beginning of the sub string
3360 ...         $szStop  (string)   Defines the end of the sub string
3361 ...     *}
3362 ... 
3363 ...     {*return
3364 ...         (array) Array of matches or null if not found
3365 ...     *}
3366 ... 
3367 ...     {*exec
3368 ...         $szStr      = "MyFunction(BBB) is beautiful (even if it's not really mine)";
3369 ...         $aMatches   = STR_aBetween( $szStr,'(',')' );
3370 ...         var_dump( $aMatches );
3371 ... 
3372 ...         echo LSUnitTesting::assert( count( $aMatches ) === 2                    ,
3373 ...                                     'ASSERTION SUCCESSFUL: correct extraction 1'  ,
3374 ...                                     'ASSERTION FAILURE: invalid extraction'     ,
3375 ...                                     'GuideAssert' );
3376 ...         $szStr      = "<html><body><p>This is what I want to extract</p></body></html>";
3377 ...         $aMatches   = STR_aBetween( $szStr,'<body>','</body>' );
3378 ...         var_dump( $aMatches );
3379 ... 
3380 ...         echo LSUnitTesting::assert( count( $aMatches ) === 1 &&
3381 ...                                     preg_match( '/<body>(.*)<\/body>/si',$aMatches[0] ) ,
3382 ...                                     'ASSERTION SUCCESSFUL: correct extraction 2'          ,
3383 ...                                     'ASSERTION FAILURE: invalid extraction'             ,
3384 ...                                     'GuideAssert' );
3385 ... 
3386 ...         $aMatches   = STR_aBetween( $szStr,'<html>','</p>' );
3387 ...         var_dump( $aMatches );
3388 ... 
3389 ...         echo LSUnitTesting::assert( $aMatches[0] === "<html><body><p>This is what I want to extract</p>",
3390 ...                                     'ASSERTION SUCCESSFUL: correct extraction 3'                          ,
3391 ...                                     'ASSERTION FAILURE: invalid extraction'                             ,
3392 ...                                     'GuideAssert' );
3393 ... 
3394 ...     *}
3395 ... 
3396 ...     *}}
3397 ...  */
3398 ... /* ========================================================================== */
3399 ... function STR_aBetween( $szStr,$szStart,$szStop )
3400 ... /*--------------------------------------------*/
3401 ... {
3402 ...     $szRegStart = chr(22);
3403 ... 
3404 ...     $szStart = str_replace( array( '\\','/','(',')','[',']' ),array( '\\\\','\/','\(','\)','\[','\]' ),$szStart );
3405 ...     $szStop  = str_replace( array( '\\','/','(',')','[',']' ),array( '\\\\','\/','\(','\)','\[','\]' ),$szStop  );
3406 ... 
3407 ...     preg_match_all( "{$szRegStart}{$szStart}(.*){$szStop}{$szRegStart}siU",$szStr,$aMatch );
3408 ... 
3409 ...     return ( $aMatch[0] );
3410 ... }   /* == End of function STR_aBetween() ==================================== */
3411 ... 
3412 ... /* ========================================================================== */
3413 ... /** {{*STR_GeneratePassword( [$iLength] )=
3414 ... 
3415 ...     Generates a password at random
3416 ... 
3417 ...     {*params
3418 ...         $iLength    (int)   Minimum length of the password to be generated.
3419 ...                             Optional. [c]-1[/c] by default, which means NO
3420 ...                             minimal length.
3421 ...     *}
3422 ... 
3423 ...     {*warning
3424 ...         Use this function with caution as it consumes some resources before
3425 ...         it returns: the password is chosen amongst more than 3000
3426 ...         possible combinations.
3427 ...     *}
3428 ... 
3429 ...     {*return
3430 ...         (string)    Password at random
3431 ...     *}
3432 ... 
3433 ...     {*author  *}
3434 ...     {*mdate 14/10/2013 06:35 *}
3435 ... 
3436 ...     {*exec
3437 ...         echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
3438 ...         echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
3439 ...                                       STR_Pos( $szWord,"\r" ) === -1    &&
3440 ...                                       STR_Pos( $szWord, "\n" ) === -1               ,
3441 ...                                     'ASSERTION SUCCESSFUL: password seems to be OK' ,
3442 ...                                     'ASSERTION FAILURE: invalid password'           ,
3443 ...                                     'GuideAssert' );
3444 ...         echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
3445 ...         echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
3446 ...                                       STR_Pos( $szWord,"\r" ) === -1    &&
3447 ...                                       STR_Pos( $szWord,"\n" )                       ,
3448 ...                                     'ASSERTION SUCCESSFUL: password seems to be OK' ,
3449 ...                                     'ASSERTION FAILURE: invalid password'           ,
3450 ...                                     'GuideAssert' );
3451 ...         echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
3452 ...         echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
3453 ...                                       STR_Pos( $szWord,"\r" ) === -1    &&
3454 ...                                       STR_Pos( $szWord,"\n" )                       ,
3455 ...                                     'ASSERTION SUCCESSFUL: password seems to be OK' ,
3456 ...                                     'ASSERTION FAILURE: invalid password'           ,
3457 ...                                     'GuideAssert' );
3458 ...         echo '<p>',$szWord = STR_GeneratePassword(8),'</p>';
3459 ...         echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
3460 ...                                       STR_Pos( $szWord,"\r" ) === -1    &&
3461 ...                                       STR_Pos( $szWord,"\n" ) === -1    &&
3462 ...                                       strlen( $szWord ) === 8                       ,
3463 ...                                     'ASSERTION SUCCESSFUL: password seems to be OK' ,
3464 ...                                     'ASSERTION FAILURE: invalid password'           ,
3465 ...                                     'GuideAssert' );
3466 ...     *}
3467 ... 
3468 ...     {*assert STR_GeneratePassword() != STR_GeneratePassword() *}
3469 ...     {*assert ! STR_Empty( STR_GeneratePassword() ) *}
3470 ... 
3471 ...     {*seealso
3472 ...         STR_Random()
3473 ...     *}
3474 ... 
3475 ...     *}}
3476 ...  */
3477 ... /* ========================================================================== */
3478 ... function STR_GeneratePassword( $iLength = -1 )
3479 ... /*------------------------------------------*/
3480 ... {
3481 ...     $aWords = explode( ' ',file_get_contents( FIL_Normalize( VAESOLI_PATH . '/../latin/416.txt' ) ) );
3482 ...     $iCount = count( $aWords );
3483 ...     $i      = 1;
3484 ... 
3485 ...     $szTheWord = str_replace( array( ',','.','!','?',';',' ',"\r","\n",'<','>' ),'',$aWords[rand(0,$iCount-1)] );
3486 ... 
3487 ...     while ( strlen( $szTheWord ) < 8 )
3488 ...     {
3489 ...         $i++;
3490 ...         $szTheWord .= (string) $i . str_replace( array( ',','.','!','?',';',' ',"\r","\n",'<','>' ),'',$aWords[rand(0,$iCount-1)] );
3491 ...     }
3492 ... 
3493 ...     $szTheWord = strtran( $szTheWord,' ','' );
3494 ... 
3495 ...     return ( $iLength === -1 ? $szTheWord : substr( STR_padr( $szTheWord,$iLength,'B' ),0,$iLength ) );
3496 ... }   /* == End of function STR_GeneratePassword() ============================ */
3497 ... 
3498 ... /* ========================================================================== */
3499 ... /** {{*STR_Random( $iLength,$iStrategy )=
3500 ... 
3501 ...     Generates string at random
3502 ... 
3503 ...     {*params
3504 ...         $iLength    (int)       Length of the string to be generated. By default
3505 ...                                 $iLength is 15 characters long.
3506 ...         $iStrategy  (int)       Strategy when generating the string. By default
3507 ...                                 digits are returned.
3508 ... 
3509 ...                                 [table]
3510 ...                                 [tr][th]Strategy[/th][th]Description[/th][/tr]
3511 ...                                 [tr][td][c]0[/c][/td][td]digits only (default)[/td][/tr]
3512 ...                                 [tr][td][c]1[/c][/td][td]uppercase letters only[/td][/tr]
3513 ...                                 [tr][td][c]2[/c][/td][td]lowercase letters only[/td][/tr]
3514 ...                                 [/table]
3515 ... 
3516 ...     *}
3517 ... 
3518 ...     {*return
3519 ...         (string)    string at random
3520 ...     *}
3521 ... 
3522 ...     {*author  *}
3523 ...     {*cdate 14/10/2013 06:49 *}
3524 ... 
3525 ...     {*exec
3526 ...         echo '<p>',$szRandom1 = STR_Random( 40 ),'</p>';
3527 ...         echo '<p>',$szRandom2 = STR_Random( 15,1 ),'</p>';
3528 ...         echo '<p>',$szRandom3 = STR_Random( 40,2 ),'</p>';
3529 ... 
3530 ...         echo LSUnitTesting::assert( strlen( $szRandom1 ) === 40                             ,
3531 ...                                     'ASSERTION SUCCESSFUL: correct length for $szRandom1'   ,
3532 ...                                     'ASSERTION FAILURE: incorrect length for $szRandom1'    ,
3533 ...                                     'GuideAssert' );
3534 ...         echo LSUnitTesting::assert( STR_dionly( $szRandom1 ) === $szRandom1                 ,
3535 ...                                     'ASSERTION SUCCESSFUL: $szRandom1 only digits'          ,
3536 ...                                     'ASSERTION FAILURE: $szRandom1 not digits only'         ,
3537 ...                                     'GuideAssert' );
3538 ...         echo LSUnitTesting::assert( strlen( $szRandom2 ) === 15                             ,
3539 ...                                     'ASSERTION SUCCESSFUL: correct length for $szRandom2'   ,
3540 ...                                     'ASSERTION FAILURE: incorrect length for $szRandom2'    ,
3541 ...                                     'GuideAssert' );
3542 ...         echo LSUnitTesting::assert( strtoupper( $szRandom2 ) === $szRandom2                 ,
3543 ...                                     'ASSERTION SUCCESSFUL: $szRandom2 only uppercase'       ,
3544 ...                                     'ASSERTION FAILURE: $szRandom2 NOT only uppercase'      ,
3545 ...                                     'GuideAssert' );
3546 ...         echo LSUnitTesting::assert( strtolower( $szRandom3 ) === $szRandom3                 ,
3547 ...                                     'ASSERTION SUCCESSFUL: $szRandom3 only lowercase'       ,
3548 ...                                     'ASSERTION FAILURE: $szRandom3 NOT only lowercase'      ,
3549 ...                                     'GuideAssert' );
3550 ...     *}
3551 ... 
3552 ...     {*seealso
3553 ...         STR_GeneratePassword()
3554 ...     *}
3555 ... 
3556 ...     *}}
3557 ...  */
3558 ... /* ========================================================================== */
3559 ... function STR_Random( $iLength = 15,$iStrategy = 0 )
3560 ... /*-----------------------------------------------*/
3561 ... {
3562 ...     $szRetVal = str_repeat( ' ',$iLength );
3563 ...     //$szRetVal = '';
3564 ... 
3565 ...     switch ( $iStrategy )
3566 ...     {
3567 ...         case 1:     $iMin = 65;         /* Uppercase */
3568 ...                     $iMax = 90;
3569 ...                     break;
3570 ...         case 2:     $iMin = 97;         /* Lowercase */
3571 ...                     $iMax = 121;
3572 ...                     break;
3573 ...         default:    $iMin = 48;         /* Digits */
3574 ...                     $iMax = 57;
3575 ...     }
3576 ... 
3577 ...     for ( $i = 0; $i < $iLength;$i++ )
3578 ...     {
3579 ...         $szRetVal[$i] = chr( mt_rand( $iMin,$iMax ) );
3580 ...         //$szRetVal[$i] = ord( mt_rand( 65,128 ) );
3581 ...     }
3582 ...     return ( $szRetVal );
3583 ... }   /* == End of function STR_Random() ====================================== */
3584 ... 
3585 ... /* ========================================================================== */
3586 ... /** {{*STR_Empty( $szStr )=
3587 ... 
3588 ...     Determines whether a string is empty or not
3589 ... 
3590 ...     {*params
3591 ...         $szStr   (string)   String to test
3592 ...     *}
3593 ... 
3594 ...     {*return
3595 ...         (bool)  true if $szStr is null or ''; false otherwise
3596 ...     *}
3597 ... 
3598 ...     {*assert
3599 ...         MISC_CastString( STR_Empty( ''       ) ) === 'true'
3600 ...     *}
3601 ...     {*assert
3602 ...         MISC_CastString( STR_Empty( null     ) ) === 'true'
3603 ...     *}
3604 ...     {*assert
3605 ...         MISC_CastString( STR_Empty( 'Hello'  ) ) === 'false'
3606 ...     *}
3607 ...     {*assert
3608 ...         MISC_CastString( STR_Empty( '     '  ) ) === 'false'
3609 ...     *}
3610 ... 
3611 ...     {*exec
3612 ...         echo '<p>',MISC_CastString( STR_Empty( ''       ) ),'</p>';
3613 ...         echo '<p>',MISC_CastString( STR_Empty( null     ) ),'</p>';
3614 ...         echo '<p>',MISC_CastString( STR_Empty( 'Hello'  ) ),'</p>';
3615 ...         echo '<p>',MISC_CastString( STR_Empty( '     '  ) ),'</p>';
3616 ...     *}
3617 ... 
3618 ...     *}}
3619 ...  */
3620 ... /* ========================================================================== */
3621 ... function STR_Empty( $szStr )
3622 ... /*------------------------*/
3623 ... {
3624 ...     return ( ( ! $szStr ) || ( @strlen( $szStr ) === 0 ) );
3625 ... }   /* End of function function STR_Empty() ================================= */
3626 ... 
3627 ... /* ========================================================================== */
3628 ... /** {{*STR_StraightenBadEncoding( $szStr )=
3629 ... 
3630 ...     Corrects few instances of bad character encoding.
3631 ... 
3632 ...     {*params
3633 ...         $szStr  (string)   String to treat. Passed by reference ... but not touched.
3634 ...     *}
3635 ... 
3636 ...     {*return
3637 ...         (string)    $szStr where some characters are turned to their known equivalent
3638 ...     *}
3639 ... 
3640 ...     {*example
3641 ...         echo STR_StraightenBadEncoding( 'C�©libataire' );  // Prints 'Célibataire'
3642 ...     *}
3643 ... 
3644 ...     *}}
3645 ...  */
3646 ... /* ========================================================================== */
3647 ... function STR_StraightenBadEncoding( &$szStr )
3648 ... /*----------------------------------------*/
3649 ... {
3650 ...     return ( str_replace( array('�©','��','�ª','� ','�š','�¢','�§','â��','�®','��' ),
3651 ...                           array('é' ,'�' ,'ê' ,'à ','Ú' ,'â' ,'ç' ,'\'' ,'î' ,'�'  ),
3652 ...                           $szStr ) );
3653 ... }   /* End of function STR_StraightenBadEncoding()=========================== */
3654 ... 
3655 ... /* ========================================================================== */
3656 ... /** {{*STR_aWords( $szStr,$iType,$szList )=
3657 ... 
3658 ...     Returns an array containing all the words found inside $szStr
3659 ... 
3660 ...     {*params
3661 ...         $szStr  (string)    String to treat
3662 ...         $iType  (int)       Type of return. Optional.
3663 ...                             0 = number of words[br]
3664 ...                             1 = array of words (default behavior);
3665 ... 
3666 ...         $szList (string)    Additional characters which will be considered
3667 ...                             as natural part of a 'word'. Optional.
3668 ...     *}
3669 ... 
3670 ...     {*return
3671 ...         (array) An array with all words found in $szStr
3672 ...     *}
3673 ... 
3674 ...     {*assert
3675 ...         count( STR_aWords( 'Hello World' ) ) === 2
3676 ...     *}
3677 ...     {*assert
3678 ...         count( STR_aWords( 'Hello World',1 ) ) === 2
3679 ...     *}
3680 ...     {*assert
3681 ...         count( STR_aWords( 'Hello World',2 ) ) === 2
3682 ...     *}
3683 ...     {*assert
3684 ...         STR_aWords( 'Hello World',0 ) === 2
3685 ...     *}
3686 ... 
3687 ...     {*exec
3688 ...         var_dump( STR_aWords( 'Hello World' ) );
3689 ...         echo STR_aWords( 'Hello World',0 );
3690 ...     *}
3691 ... 
3692 ...     {*seealso
3693 ...         STR_aUniqueWords()
3694 ...     *}
3695 ... 
3696 ...     {*alias
3697 ...         STR_Words()
3698 ...     *}
3699 ... 
3700 ...     *}}
3701 ...  */
3702 ... /* ========================================================================== */
3703 ... function STR_aWords( $szStr,$iType = 1,$szList = 'àáâãÀåÊÚéêëìíîï�òó�õöùúûÌÿÜ·' )
3704 ... /*----------------------------------------------------------------------------*/
3705 ... {
3706 ...     return ( str_word_count( $szStr,$iType,$szList ) );
3707 ... }   /* End of function STR_aWords() ========================================= */
3708 ... function STR_Words( $szStr,$iType = 1,$szList = 'àáâãÀåÊÚéêëìíîï�òó�õöùúûÌÿÜ·' ) { return STR_aWords( $szStr,$iType,$szList ); }
3709 ... 
3710 ... /* ========================================================================== */
3711 ... /** {{*STR_aUniqueWords( $szStr )=
3712 ... 
3713 ...     Taxonomize a string
3714 ... 
3715 ...     {*params
3716 ...         $szStr      (string)    The text whose words must be extracted
3717 ...     *}
3718 ... 
3719 ...     {*return
3720 ...         (array)     An array of words found in $szStr. The words are sorted in
3721 ...                     such a way that the most frequent words appear first.
3722 ...     *}
3723 ... 
3724 ...     {*author  *}
3725 ...     {*version 6.0.0001 *}
3726 ... 
3727 ...     {*warning
3728 ...         Experimental function. Do not use in a production environment yet
3729 ...         (22-04-14 15:24:22)
3730 ...     *}
3731 ... 
3732 ...     {*exec
3733 ...         $szStr = 'Project prioritization ... Agility: the power of moving '             .
3734 ...                  'quickly and easily. Ability to think and draw conclusions '           .
3735 ...                  'quickly; intellectual acuity", this is what we need to bear in '      .
3736 ...                  'mind when we speak about "Agile Methods"! Now think about the '       .
3737 ...                  'way estimates are requested, think about the way people make '        .
3738 ...                  'them, think about the way it is required to refine them in '          .
3739 ...                  'multiple rounds, think about the way they serve '                     .
3740 ...                  '"negotiations/bargains", think of how the value of a project is '     .
3741 ...                  'calculated, evaluated or forged, think ... Are we really agile in '   .
3742 ...                  'these matters? No, we\'re not! We\'ve outgrown all that now and '     .
3743 ...                  'it\'s to us to update the unwritten rules of Project Portfolio '      .
3744 ...                  'Management, of Project Management and of Product Development. '       .
3745 ...                  'It\'s up to us to change the rules of how agility should be '         .
3746 ...                  'embraced when dealing with all the processes we must follow. '        .
3747 ...                  'With this post we shall introduce a surprising way to weight '        .
3748 ...                  'projects and how to prioritize them in minutes instead of hours '     .
3749 ...                  'or even days or weeks! That\'s a way to become agile in that '        .
3750 ...                  'matter. <strong>It\'s LEAN!</strong>';
3751 ...         $aWords = STR_aUniqueWords( $szStr );
3752 ...         var_dump( $aWords );
3753 ... 
3754 ...         echo LSUnitTesting::assert( count( $aWords ) === 84                         ,
3755 ...                                     'ASSERTION SUCCESSFUL: correct number of words' ,
3756 ...                                     'ASSERTION FAILURE: incorrect number of words'  ,
3757 ...                                     'GuideAssert' );
3758 ...     *}
3759 ... 
3760 ...     {*seealso
3761 ...         STR_Words()
3762 ...     *}
3763 ... 
3764 ...     *}}
3765 ...  */
3766 ... /* ========================================================================== */
3767 ... function STR_aUniqueWords( $szStr )
3768 ... /*-------------------------------*/
3769 ... {
3770 ...     //http://www.relooking.be/site/sfr/fold/visagisme
3771 ...     /* {*require (LSHtml.functions.php)     HTML functions *} */
3772 ...     require_once( VAESOLI_PATH . '/LSHtml.functions.php' );
3773 ... 
3774 ...     $aUniqueWords       = array();                                  /* Return value of the function */
3775 ...     $aParams            = array();                                  /* Array of parameters for the HTML_CleanUp() function */
3776 ... 
3777 ...     //$aParams['gtlt'   ] = true;
3778 ...     $aParams['script' ] = true;
3779 ...     $aParams['style'  ] = true;
3780 ...     $aParams['tags'   ] = true;
3781 ...     $aParams['doctype'] = true;
3782 ...     $aParams['marks'  ] = true;
3783 ...     $aParams['punct'  ] = true;
3784 ...     $aParams['braces' ] = true;
3785 ...     $aParams['spaces' ] = true;
3786 ... 
3787 ...     //echo "\n\n<p>ORIGINAL STRING</p>\n";
3788 ...     //echo $szStr;
3789 ... 
3790 ...     //echo "\n<n<p>STRAIGHTEN</p>\n";
3791 ...     //$szStr  = STR_StraightenBadEncoding( $szStr );        /* HTML cleanup + all accents eliminated */
3792 ...     //echo $szStr;
3793 ... 
3794 ...     //echo "\n\n<p>AEIOUY</p>\n";
3795 ...     //$szStr  = STR_aeiouy( $szStr );        /* HTML cleanup + all accents eliminated */
3796 ...     //$szStr = unhtmlentities( $szStr );
3797 ...     //echo $szStr;
3798 ... 
3799 ... 
3800 ...     //echo "\n\n<p>PURE STRING (CLEANUP, ...)</p>\n";
3801 ...     $szStr  = HTML_CleanUp( $szStr,$aParams );        /* HTML cleanup + all accents eliminated */
3802 ...     //echo $szStr;
3803 ... 
3804 ... 
3805 ...     $iCount = count( $aAllWords = STR_Words( $szStr ) );            /* Get an array of words contained in the original string */
3806 ... 
3807 ...     //echo "<p>",__METHOD__,"() at line ",__LINE__,": PURE WORDS</p>";
3808 ...     //var_dump( $aAllWords );
3809 ... 
3810 ...     /* Turn all words to lowercase */
3811 ...     for ( $i=0;$i < $iCount;$i++ )
3812 ...     {
3813 ...         $aAllWords[$i] = strtolower( $aAllWords[$i] );
3814 ...     }   /* for ( $i=0;$i < $iCount;$i++ ) */
3815 ... 
3816 ...     //echo "<p>APRES LOWERCASE</p>";
3817 ...     //var_dump( $aAllWords );
3818 ... 
3819 ... 
3820 ...     /* This will generate an array of UNIQUE words and for each
3821 ...        word a count of occurences
3822 ... 
3823 ...         Array
3824 ...         (
3825 ...             [hello] => 2
3826 ...             [world] => 1
3827 ...         )
3828 ... 
3829 ...     */
3830 ...     $aUniqueWords = array_count_values( $aAllWords );
3831 ... 
3832 ...     //echo "<p>TOUS LES MOTS UNIQUES</p>";
3833 ...     //var_dump( $aUniqueWords );
3834 ... 
3835 ... 
3836 ...     /* Get rid of all words less than 3 chars long */
3837 ...     foreach ( $aUniqueWords as $szWord => $iCount )
3838 ...     {
3839 ...         if ( strlen( $szWord ) < 3 )
3840 ...         {
3841 ...             unset( $aUniqueWords[$szWord] );
3842 ...         }
3843 ...     }
3844 ... 
3845 ...     //echo "<p>TOUS LES MOTS UNIQUES DE 3 LETTRES AU MOINS</p>";
3846 ...     //var_dump( $aUniqueWords );
3847 ... 
3848 ...     /* This will sort the array on the count of occurrences -
3849 ...        lowest occurrence at the bottom of the array */
3850 ...     arsort( $aUniqueWords,SORT_NUMERIC );
3851 ... 
3852 ...     //echo "<p>TOUS LES MOTS UNIQUES TRIÃ?S</p>";
3853 ...     //var_dump( $aUniqueWords );
3854 ... 
3855 ... 
3856 ...     return ( $aUniqueWords );
3857 ... }
3858 ... 
3859 ... /* ====================================================================== */
3860 ... /** {{*STR_Dionly( $szStr )=
3861 ... 
3862 ...     Keeps only the digits of a string
3863 ... 
3864 ...     {*params
3865 ...         $szStr   (string)   String to process
3866 ...     *}
3867 ... 
3868 ...     {*alias
3869 ...         dionly(), STR_DigitsOnly()
3870 ...     *}
3871 ... 
3872 ...     {*return
3873 ...         (string)            $szStr from which we kept the digits only
3874 ...     *}
3875 ... 
3876 ...     {*example
3877 ...         echo STR_Dionly( "I love these 101 dogs" );     // "101"
3878 ...     *}
3879 ... 
3880 ...     {*assert
3881 ...         STR_Dionly( 'This 1000 stars sky is less beautiful than your 2 eyes' ) === '10002'
3882 ...     *}
3883 ... 
3884 ...     {*assert
3885 ...         STR_Dionly( "    I love these 101 dogs   " ) === "101"
3886 ...     *}
3887 ... 
3888 ...     *}}
3889 ...  */
3890 ... /* ====================================================================== */
3891 ... function STR_Dionly( $szStr )
3892 ... /*-------------------------*/
3893 ... {
3894 ...     $szRetVal   = '';                                               /* Return value of the function */
3895 ...     $iLen       = strlen( $szStr );                                 /* Length of string */
3896 ... 
3897 ...     for( $i=0;$i<$iLen;$i++ )                                       /* For each char in string */
3898 ...     {
3899 ...         $c = $szStr[$i];                                            /* Get the character */
3900 ... 
3901 ...         if ( isdigit( $c ) )                                        /* If that's a digit */
3902 ...         {
3903 ...             $szRetVal .= $c;                                        /* Concatenate in result */
3904 ...         }   /* if ( isdigit( $c ) ) */
3905 ...     }   /* for( $i=0;$i<$iLen;$i++ ) */
3906 ... 
3907 ...     return ( $szRetVal );                                           /* Return result to caller */
3908 ... }   /* End of function function STR_dionly() */
3909 ... /* ====================================================================== */
3910 ... function dionly( $szStr )           { return ( STR_dionly( $szStr ) ); }
3911 ... function STR_dionly2( $szStr )      { return ( STR_dionly( $szStr ) ); }
3912 ... function STR_DigitsOnly( $szStr )   { return ( STR_dionly( $szStr ) ); }
3913 ... 
3914 ... /* ====================================================================== */
3915 ... /** {{*STR_isdigit( $szStr )=
3916 ... 
3917 ...     Determines if the first character of a string is a digit
3918 ... 
3919 ...     {*params
3920 ...         $szStr   (string)   String to process ([b]1st character only[/b])
3921 ...     *}
3922 ... 
3923 ...     {*alias
3924 ...         isdigit()
3925 ...     *}
3926 ... 
3927 ...     {*return
3928 ...         (bool)  true if $szStr[0] is 0 ... 9
3929 ...     *}
3930 ... 
3931 ...     {*example
3932 ...         echo MISC_CastString( STR_isdigit( '9a' ) );    // "true"
3933 ...         echo MISC_CastString( STR_isdigit( '9'  ) );    // "true"
3934 ...         echo MISC_CastString( STR_isdigit( 'H909' ) );  // "false"
3935 ...     *}
3936 ... 
3937 ...     {*assert
3938 ...         MISC_CastString( STR_isdigit( '9a' ) ) === "true"
3939 ...     *}
3940 ... 
3941 ...     {*assert
3942 ...         MISC_CastString( STR_isdigit( '9'  ) ) === "true"
3943 ...     *}
3944 ... 
3945 ...     {*assert
3946 ...         MISC_CastString( STR_isdigit( 'H909' ) ) === "false"
3947 ...     *}
3948 ... 
3949 ...     *}}
3950 ...  */
3951 ... /* ========================================================================== */
3952 ... function STR_isdigit( $szStr )
3953 ... {
3954 ...     $x = ord( $szStr );
3955 ...     return ( ( $x >= 48 ) && ( $x <= 57 ) );
3956 ... }   /* End of function function STR_isdigit() */
3957 ... /* ========================================================================== */
3958 ... function isdigit( $szStr )     { return ( STR_isdigit( $szStr ) ); }
3959 ... 
3960 ... /* ========================================================================== */
3961 ... /** {{*STR_padl( $szStr,$iLength,$szPadding )=
3962 ... 
3963 ...     Left padding of a string
3964 ... 
3965 ...     {*params
3966 ...         $szStr      (string)    String to pad
3967 ...         $iLength    (int)       Length of resulting string
3968 ...         $szPadding  (string)    Padding character. Optional. By default ' '.
3969 ...     *}
3970 ... 
3971 ...     {*keywords
3972 ...         padding, left padding
3973 ...     }
3974 ... 
3975 ...     {*return
3976 ...         (string)    The resulting string, left padded with $szPadding
3977 ...     *}
3978 ... 
3979 ...     {*example
3980 ...         echo STR_padl( '101',6,'0' );  // '000101'
3981 ...         echo STR_padl( '101',6     );  // '   101'
3982 ...     *}
3983 ... 
3984 ...     {*seealso
3985 ...         STR_padr()
3986 ...     *}
3987 ... 
3988 ...     {*assert
3989 ...         STR_padl( '101',6,'0' ) === '000101'
3990 ...     *}
3991 ... 
3992 ...     {*assert
3993 ...         STR_padl( '101',6     ) === '   101'
3994 ...     *}
3995 ... 
3996 ...     *}}
3997 ...  */
3998 ... /* ========================================================================== */
3999 ... function STR_padl( $szStr,$iLength,$szPadding = ' ' )
4000 ... /*-------------------------------------------------*/
4001 ... {
4002 ...     return ( str_pad( (string) $szStr,$iLength,$szPadding,STR_PAD_LEFT ) );
4003 ... }   /* End of function function STR_padl() ================================== */
4004 ... 
4005 ... /* ========================================================================== */
4006 ... /** {{*STR_padr( $szStr,$iLength,$szPadding )=
4007 ... 
4008 ...     Right padding of a string
4009 ... 
4010 ...     {*params
4011 ...         $szStr      (string)    String to pad
4012 ...         $iLength    (int)       Length of resulting string
4013 ...         $szPadding  (string)    Padding character. Optional. By default ' '.
4014 ...     *}
4015 ... 
4016 ...     {*keywords
4017 ...         padding, right padding
4018 ...     *}
4019 ... 
4020 ...     {*return
4021 ...         (string)    The resulting string, right padded with $szPadding
4022 ...     *}
4023 ... 
4024 ...     {*example
4025 ...         echo STR_padr( '101',6,'0' );  // '101000'
4026 ...         echo STR_padr( '101',6     );  // '101   '
4027 ...     *}
4028 ... 
4029 ...     {*seealso
4030 ...         STR_padl()
4031 ...     *}
4032 ... 
4033 ...     {*assert
4034 ...         STR_padr( '101',6,'0' ) === '101000'
4035 ...     *}
4036 ... 
4037 ...     {*assert
4038 ...         STR_padr( '101',6     ) === '101   '
4039 ...     *}
4040 ... 
4041 ...     *}}
4042 ...  */
4043 ... /* ========================================================================== */
4044 ... function STR_padr( $szStr,$iLength,$szPadding = ' ' )
4045 ... /*-------------------------------------------------*/
4046 ... {
4047 ...     return ( str_pad( (string) $szStr,$iLength,$szPadding,STR_PAD_RIGHT ) );
4048 ... }   /* End of function function STR_padr() ================================== */
4049 ... 
4050 ... /* ========================================================================== */
4051 ... /** {{*STR_aLines( $szStr )=
4052 ... 
4053 ...     Splits a string into lines
4054 ... 
4055 ...     {*params
4056 ...         $szStr      (string)    String to slice in lines
4057 ...     *}
4058 ... 
4059 ...     {*warning
4060 ...         Empty lines are disregarded
4061 ...     *}
4062 ... 
4063 ...     {*return
4064 ...         (array)         Each cell of the array is a line. Empty lines are NOT
4065 ...                         taken into account (spaces are NOT considered as
4066 ...                         empty characters).
4067 ...     *}
4068 ... 
4069 ...     {*exec
4070 ...         $szCode  = "\r\n";
4071 ...         $szCode .= "             \r\n";
4072 ...         $szCode .= '                    echo \'<p>\',$iDate1=SetExpiry( 2012,12,31,23,59,59 ),\'</p>\'; // 1972387238399' . "\r\n";
4073 ...         $szCode .= '        echo \'<p>\',$iDate2=SetExpiry( 2015,1,1 ),\'</p>\';            // 1975295980800' . "\r\n";
4074 ...         $szCode .= '        if ( $iDate2 > $iDate1 )' . "\r\n";
4075 ...         $szCode .= '        {' . "\r\n";
4076 ...         $szCode .= '            echo \'<p>$iDate2 &gt; $iDate1</p>\';' . "\r\n";
4077 ...         $szCode .= '        }';
4078 ... 
4079 ...         $aLines  = STR_aLines( $szCode );
4080 ...         // 'There are 7 lines of code' ... because the 1st one is empty
4081 ...         echo "<p>There are " . ( $iCount = count( $aLines ) ) .
4082 ...                  " lines of code</p>\n";
4083 ...         var_dump( $aLines );
4084 ...         echo LSUnitTesting::assert( $iCount === 7,
4085 ...                                     'ASSERTION SUCCESSFUL: lines correctly counted',
4086 ...                                     'ASSERTION FAILURE: lines incorrectly counted',
4087 ...                                     'GuideAssert' );
4088 ...     *}
4089 ... 
4090 ...     *}}
4091 ...  */
4092 ... /* ========================================================================== */
4093 ... function STR_aLines( $szStr )
4094 ... /*-------------------------*/
4095 ... {
4096 ...     /* CRLF     turned to CHR(1)
4097 ...        CR       turned to CRLF
4098 ...        LF       turned to CRLF
4099 ...        CHR(1)   turned to CRLF */
4100 ...     $szStr = str_replace( array("\r","\n",chr(1) ),"\r\n",str_replace( "\r\n",chr(1),$szStr ) );
4101 ...     return ( preg_split( '/\r\n*?/',$szStr,-1,PREG_SPLIT_NO_EMPTY ) );
4102 ... }   /* == End of function STR_aLines() ================================== */
4103 ... 
4104 ... /* ====================================================================== */
4105 ... /** {{*STR_AddCode( $szStr,$iCode )=
4106 ... 
4107 ...     Adds an ASCII code to each character of a string.
4108 ... 
4109 ...     {*params
4110 ...         $szStr      (string)    String to process
4111 ...         $iCode        (int)       ASCII code to add to each character.
4112 ...     *}
4113 ... 
4114 ...     {*return
4115 ...         (string)    Resulting string
4116 ...     *}
4117 ... 
4118 ...     {*assert
4119 ...         STR_AddCode( "12345678",1 ) === "23456789"
4120 ...     *}
4121 ... 
4122 ...     {*assert
4123 ...         STR_AddCode( "Hello World",255 ) === "Hello World"
4124 ...     *}
4125 ... 
4126 ...     {*assert
4127 ...         STR_AddCode( "Hello World",256 ) === "Ifmmp!Xpsme"
4128 ...     *}
4129 ... 
4130 ...     {*assert
4131 ...         STR_AddCode( "   ",1 ) === "!!!"
4132 ...     *}
4133 ... 
4134 ...     {*example
4135 ...         echo STR_AddCode( "12345678",1 );    Prints "23456789"
4136 ...     *}
4137 ... 
4138 ...     *}}
4139 ...  */
4140 ... /* ====================================================================== */
4141 ... function STR_AddCode( $szStr,$iCode )
4142 ... /*---------------------------------*/
4143 ... {
4144 ...     $iLength  = strlen( $szStr );                                   /* Length of the string */
4145 ... 
4146 ...     for ( $i=0;$i<$iLength;$i++ )                                   /* For each character of the string */
4147 ...     {
4148 ...         /* Set the character we're on to its ASCII value + $iCode
4149 ...           (modulo 255 just to make sure we stay within ASCII boundaries) */
4150 ...         $szStr[$i] = chr( ( ord( $szStr[$i] ) + $iCode ) % 255 );
4151 ...     }   /* for ( $i=0;$i<$iLength;$i++ ) */
4152 ... 
4153 ...     return ( $szStr );                                              /* Return result to caller */
4154 ... }   /* == End of function STR_AddCode() ================================= */
4155 ... 
4156 ... /* ====================================================================== */
4157 ... /** {{*STR_AllChars( $szStr[,$iType] )=
4158 ... 
4159 ...     Returns all the characters found in a string in a sorted manner.
4160 ... 
4161 ...     {*params
4162 ...         $szStr      (string)    String to process
4163 ...         $iType        (int)       Optional. Type of treatment:[br]
4164 ...                                 0 ... case-sensitive (default)[br]
4165 ...                                 1 ... uses uppercase algorithm[br]
4166 ...                                 2 ... uses lowercase algorithm.
4167 ...     *}
4168 ... 
4169 ...     {*remark
4170 ...         This algorithm is used in SCRABBLE for example ... to locate ANY
4171 ...         word that contains all letters, or 7 letters, or 6 letters, etc.
4172 ...         Each character of the original string will be reported only once
4173 ...         in the resulting string.
4174 ...     *}
4175 ... 
4176 ...     {*return
4177 ...         (string)    Resulting string. If $iType == 1, the returned string
4178 ...                     is in uppercase; if $iType == 2, the returned string
4179 ...                     is in lowercase.
4180 ...     *}
4181 ... 
4182 ...     {*assert
4183 ...         STR_AllChars( "Hello World"   ) === " HWdelor"
4184 ...     *}
4185 ... 
4186 ...     {*assert
4187 ...         STR_AllChars( "Hello World",0 ) === " HWdelor"
4188 ...     *}
4189 ... 
4190 ...     {*assert
4191 ...         STR_AllChars( "Hello World",1 ) === " DEHLORW"
4192 ...     *}
4193 ... 
4194 ...     {*assert
4195 ...         STR_AllChars( "Hello World",2 ) === " dehlorw"
4196 ...     *}
4197 ... 
4198 ...     {*assert
4199 ...         STR_AllChars( "Hello World",5 ) === " HWdelor"
4200 ...     *}
4201 ... 
4202 ...     {*example
4203 ...         $szString = "Hello World"
4204 ... 
4205 ...         echo STR_AllChars( $szString   ) // " HWdelor"
4206 ...         echo STR_AllChars( $szString,0 ) // " HWdelor"
4207 ...         echo STR_AllChars( $szString,1 ) // " DEHLORW"
4208 ...         echo STR_AllChars( $szString,2 ) // " dehlorw"
4209 ...     *}
4210 ... 
4211 ...     *}}
4212 ...  */
4213 ... /* ====================================================================== */
4214 ... function STR_AllChars( $szStr,$iType = 0 )
4215 ... /*--------------------------------------*/
4216 ... {
4217 ...     $aLetters = array();                                            /* Return value of the function */
4218 ...     $iLength  = strlen( $szStr );                                   /* Length of the string */
4219 ...     for ( $i=0;$i<$iLength;$i++ )                                   /* For each character of the string */
4220 ...     {
4221 ...         if ( ! isset( $aLetters[ $c = $szStr[$i] ] ) )              /* If letter NOT encountered yet */
4222 ...         {
4223 ...             $aLetters[$c] = 1;                                      /* Save it */
4224 ...         }
4225 ...     }   /* for ( $i=0;$i<$iLength;$i++ ) */
4226 ... 
4227 ...     switch ( $iType )
4228 ...     {
4229 ...         case    1   :   uksort( $aLetters,'__AllCharsCmpUpper' );
4230 ...                         break;
4231 ...         case    2   :   uksort( $aLetters,'__AllCharsCmpLower' );
4232 ...                         break;
4233 ...         default     :   ksort( $aLetters );
4234 ...                         break;
4235 ...     }
4236 ... 
4237 ...     //$szRetVal = implode( '',$aLetters) ;
4238 ...     $szRetVal ='';
4239 ... 
4240 ...     foreach( $aLetters as $cLetter => $iValue )
4241 ...     {
4242 ...         $szRetVal .= $cLetter;
4243 ...     }
4244 ... 
4245 ...     if     ( $iType === 1 )
4246 ...     {
4247 ...         $szRetVal = strtoupper( $szRetVal );
4248 ...     }
4249 ...     elseif ( $iType === 2 )
4250 ...     {
4251 ...         $szRetVal = strtolower( $szRetVal );
4252 ...     }
4253 ... 
4254 ...     return ( $szRetVal );                                           /* Return result to caller */
4255 ... }   /* == End of function STR_AllChars() ================================ */
4256 ... 
4257 ... function __AllCharsCmpUpper( $a,$b )
4258 ... /*--------------------------------*/
4259 ... {
4260 ...     if ( ( $a = strtoupper( $a ) ) < $b = ( strtoupper( $b ) ) )
4261 ...     {
4262 ...         return ( -1 );
4263 ...     }
4264 ...     elseif ( $a === $b )
4265 ...     {
4266 ...         return ( 0 );
4267 ...     }
4268 ...     else
4269 ...     {
4270 ...         return ( 1 );
4271 ...     }
4272 ... }
4273 ... 
4274 ... function __AllCharsCmpLower( $a,$b )
4275 ... /*--------------------------------*/
4276 ... {
4277 ...     if ( ( $a = strtolower( $a ) ) < $b = ( strtolower( $b ) ) )
4278 ...     {
4279 ...         return ( -1 );
4280 ...     }
4281 ...     elseif ( $a === $b )
4282 ...     {
4283 ...         return ( 0 );
4284 ...     }
4285 ...     else
4286 ...     {
4287 ...         return ( 1 );
4288 ...     }
4289 ... }
4290 ... 
4291 ... /* ====================================================================== */
4292 ... /** {{*STR_Hexa( $szStr )=
4293 ... 
4294 ...     Turns a string to an hexa equivalent
4295 ... 
4296 ...     {*params
4297 ...         $szStr      (string)    String to transform into a suite of hex values
4298 ...     *}
4299 ... 
4300 ...     {*alias
4301 ...         STR_stoh()
4302 ...     *}
4303 ... 
4304 ...     {*return
4305 ...         (string)    $szStr is transformed into hex equivalents
4306 ...     *}
4307 ... 
4308 ...     {*exec
4309 ...         echo STR_Hexa( "Hello World" );
4310 ...     *}
4311 ... 
4312 ...     {*assert STR_htos( STR_Hexa( $szStr = "Hello World" ) ) === $szStr *}
4313 ... 
4314 ...     {*seealso
4315 ...         STR_htos()
4316 ...     *}
4317 ... 
4318 ...     *}}
4319 ...  */
4320 ... /* ========================================================================== */
4321 ... function STR_Hexa( $szStr )
4322 ... /*-----------------------*/
4323 ... {
4324 ...     $iLength  = strlen( $szStr );
4325 ...     $szResult = '';
4326 ... 
4327 ...     for ( $i=0;$i < $iLength;$i++ )
4328 ...     {
4329 ...         $szResult  .= sprintf( '%02x',ord( $szStr[$i] ) );
4330 ...     }
4331 ... 
4332 ...     return ( $szResult );
4333 ... }   /* == End of function STR_Hexa() ======================================== */
4334 ... function STR_stoh( $szStr ) { return ( STR_Hexa( $szStr ) ); }
4335 ... 
4336 ... /* ========================================================================== */
4337 ... /** {{*STR_htos( $szStr )=
4338 ... 
4339 ...     Opposite function to [c]STR_hexa()[/c]
4340 ... 
4341 ...     {*params
4342 ...         $szStr      (string)    Hex values turned to a string equivalent
4343 ...     *}
4344 ... 
4345 ...     {*return
4346 ...         (string)    $szStr is transformed into a string equivalent
4347 ...     *}
4348 ... 
4349 ...     {*exec
4350 ...         echo $szStr = STR_htos( STR_hexa( "Hello World" ) );
4351 ...     *}
4352 ... 
4353 ...     {*assert STR_htos( STR_Hexa( $szStr = "Hello World" ) ) === $szStr *}
4354 ... 
4355 ...     {*mdate 22-04-14 19:55:11 *}
4356 ... 
4357 ...     {*seealso
4358 ...         STR_hexa()
4359 ...     *}
4360 ... 
4361 ...     *}}
4362 ...  */
4363 ... /* ========================================================================== */
4364 ... function STR_htos( $szStr )
4365 ... /*-----------------------*/
4366 ... {
4367 ...     $iLength  = strlen( $szStr );
4368 ...     $szResult = '';
4369 ... 
4370 ...     for ( $i=0;$i < $iLength;$i += 2 )
4371 ...     {
4372 ...         $szResult .= chr( hexdec( substr( $szStr,$i,2 ) ) );
4373 ...     }
4374 ... 
4375 ...     return ( $szResult );
4376 ... }   /* == End of function STR_htos() ======================================== */
4377 ... 
4378 ... /* ========================================================================== */
4379 ... /** {{*STR_Left( $szStr,$iCount )=
4380 ... 
4381 ...     Returns the $iCount leftmost characters of $szStr
4382 ... 
4383 ...     {*params
4384 ...         $szStr      (string)    the string to process
4385 ...         $iCount     (int)       specifies the number of characters returned
4386 ...                                 from the character expression. This parameter
4387 ...                                 is optional. If $iCount is not specified,
4388 ...                                 only the leftmost character of $szStr is
4389 ...                                 returned.
4390 ...     *}
4391 ... 
4392 ...     {*alias
4393 ...         strleft()
4394 ...     *}
4395 ... 
4396 ...     {*return
4397 ...         (string)    the $iCount leftmost characters of $szStr
4398 ...     *}
4399 ... 
4400 ...     {*assert
4401 ...         STR_Left( 'Hello World',5 ) === 'Hello'
4402 ...     *}
4403 ... 
4404 ...     {*assert
4405 ...         STR_Left( 'Hello World' ) === 'H'
4406 ...     *}
4407 ... 
4408 ...     {*seealso
4409 ...         STR_Right()
4410 ...     *}
4411 ...     *}}
4412 ...  */
4413 ... /* ========================================================================== */
4414 ... function STR_Left( $szStr,$iCount = 1 )
4415 ... /*----------------------------------*/
4416 ... {
4417 ...     return substr( $szStr,0,$iCount );
4418 ... }   /* End of function STR_Left() =========================================== */
4419 ... function strleft( $szStr,$iCount = 1 )  { return ( STR_Left( $szStr,$iCount ) ); }
4420 ... 
4421 ... /* ========================================================================== */
4422 ... /** {{*STR_Right( $szStr,$iCount )=
4423 ... 
4424 ...     Returns the $iCount rightmost characters of $szStr
4425 ... 
4426 ...     {*params
4427 ...         $szStr      (string)    the string to process
4428 ...         $iCount     (int)       specifies the number of characters returned
4429 ...                                 from the character expression. This parameter
4430 ...                                 is optional. If $iCount is not specified,
4431 ...                                 only the leftmost character of $szStr is
4432 ...                                 returned.
4433 ...     *}
4434 ... 
4435 ...     {*alias
4436 ...         strright(), STR_Last()
4437 ...     *}
4438 ... 
4439 ...     {*return
4440 ...         (string)    the $iCount rightmost characters of $szStr
4441 ...     *}
4442 ... 
4443 ...     {*author  *}
4444 ...     {*mdate 14/10/2013 07:17 *}
4445 ... 
4446 ...     {*assert
4447 ...         STR_Right( 'Hello World',5 ) === 'World'
4448 ...     *}
4449 ... 
4450 ...     {*assert
4451 ...         STR_Right( 'Hello World' ) === 'd'
4452 ...     *}
4453 ... 
4454 ...     {*seealso
4455 ...         STR_Left()
4456 ...     *}
4457 ... 
4458 ...     *}}
4459 ...  */
4460 ... /* ========================================================================== */
4461 ... function STR_Right( $szString,$iCount = 1 )
4462 ... /*---------------------------------------*/
4463 ... {
4464 ...     return substr( $szString,0 + strlen( $szString ) - $iCount,$iCount );
4465 ... }   /* End of function STR_Right() ========================================== */
4466 ... function strright(  $szStr,$iCount )     { return ( STR_Right( $szStr,$iCount ) ); }
4467 ... 
4468 ... /* ========================================================================== */
4469 ... /** {{*STR_Tran( $szStr,$szToReplace,$szReplacement )=
4470 ... 
4471 ...     Transforms every occurrence of $szToReplace by $szReplacement in $szString
4472 ... 
4473 ...     {*params
4474 ...         $szStr          (string)    string to process
4475 ...         $szToReplace    (string)    substring to replace with $szReplacement
4476 ...         $szReplacement  (string)    substition string for $szToReplace
4477 ...     *}
4478 ... 
4479 ...     {*alias
4480 ...         STR_Tran()
4481 ...     *}
4482 ... 
4483 ...     {*return
4484 ...         (string)    the transformed string
4485 ...     *}
4486 ... 
4487 ...     {*assert
4488 ...         STR_Tran( 'Hello World','l','' ) === 'Heo Word'
4489 ...     *}
4490 ... 
4491 ...     {*seealso
4492 ...         STR_iTran()
4493 ...     *}
4494 ...     *}}
4495 ...  */
4496 ... /* ========================================================================== */
4497 ... function STR_Tran( $szStr,$szToReplace,$szReplacement = '' )
4498 ... /*----------------------------------------------------------*/
4499 ... {
4500 ...    return ( str_replace( $szToReplace,$szReplacement,$szStr ) );
4501 ... }   /* End of function STR_tran() =========================================== */
4502 ... function strtran( $szStr,$szToReplace,$szReplacement = '' ) { return ( STR_Tran( $szStr,$szToReplace,$szReplacement ) ); }
4503 ... 
4504 ... /* ========================================================================== */
4505 ... /** {{*STR_iTran( $szString,$szToReplace,$szReplacement )=
4506 ... 
4507 ...     Transforms every occurrence of $szToReplace by $szReplacement in $szString
4508 ...     (case insensitive)
4509 ... 
4510 ...     {*params
4511 ...         $szString       (string)    string to process
4512 ...         $szToReplace    (string)    substring to replace with $szReplacement
4513 ...         $szReplacement  (string)    substition string for $szToReplace
4514 ...     *}
4515 ... 
4516 ...     {*alias
4517 ...         STR_iTran()
4518 ...     *}
4519 ... 
4520 ...     {*return
4521 ...         (string)    the transformed string
4522 ...     *}
4523 ... 
4524 ...     {*assert
4525 ...         STR_iTran( 'HeLLo World','l','' ) === 'Heo Word'
4526 ...     *}
4527 ... 
4528 ...     {*seealso
4529 ...         STR_iTran()
4530 ...     *}
4531 ...     *}}
4532 ...  */
4533 ... /* ========================================================================== */
4534 ... function STR_iTran( $szString,$szToReplace,$szReplacement = '' )
4535 ... /*------------------------------------------------------------*/
4536 ... {
4537 ...    return ( str_ireplace( $szToReplace,$szReplacement,$szString ) );
4538 ... }   /* End of function strtran() */
4539 ... function stritran( $szString,$szToReplace,$szReplacement = '' ) { return ( STR_iTran( $szString,$szToReplace,$szReplacement ) ); }
4540 ... /* ========================================================================== */
4541 ... 
4542 ... /* ========================================================================== */
4543 ... /** {{*STR_StartsWith( $szStr,$szStart )=
4544 ... 
4545 ...     Determines if $szStr starts with $szStart
4546 ... 
4547 ...     {*params
4548 ...         $szStr      (string)    the string to examine
4549 ...         $szStart    (string)    the string to look for
4550 ...     *}
4551 ... 
4552 ...     {*return
4553 ...         (boolean)   true if $szStr starts with $szStart
4554 ...     *}
4555 ... 
4556 ...     {*assert
4557 ...         STR_StartsWith( '.php=return (int) date( "d" );','.php=' ) === true
4558 ...     *}
4559 ... 
4560 ...     {*example
4561 ...         echo MISC_CastString( STR_StartsWith( 'Hello World','Hello' ) ); // Prints 'true'
4562 ...     *}
4563 ... 
4564 ...     {*seealso
4565 ...         STR_Left(), STR_EndsWith()
4566 ...     *}
4567 ... 
4568 ...     {*alias
4569 ...         STR_StartWith()
4570 ...     *}
4571 ... 
4572 ...     *}}
4573 ...  */
4574 ... /* ========================================================================== */
4575 ... function STR_StartsWith( $szStr,$szStart )
4576 ... /*-------------------------------------*/
4577 ... {
4578 ...     $bRetVal = false;                                               /* Return value of the function */
4579 ...     $iLength = strlen( $szStart );                                  /* Length of $szStart */
4580 ... 
4581 ...     if ( ! STR_Empty( $szStr ) && ( $iLength > 0 ) )                /* If all seems to be OK */
4582 ...     {
4583 ...         $bRetVal = ( STR_Left( $szStr,$iLength ) === $szStart );    /* Compare strings */
4584 ...     }   /* if ( ! STR_Empty( $szStr ) && ( $iLength > 0 ) ) */
4585 ... 
4586 ...     return ( $bRetVal );                                            /* Return result to caller */
4587 ... } /* End of function STR_StartsWith() ======================================= */
4588 ... function STR_StartWith( $szStr,$szStart ) { return ( STR_StartsWith( $szStr,$szStart ) ); }
4589 ... 
4590 ... /* ========================================================================== */
4591 ... /** {{*STR_EndsWith( $szStr,$szEnd )=
4592 ... 
4593 ...     Determines if $szStr ends with $szEnd
4594 ... 
4595 ...     {*params
4596 ...         $szStr  (string)    the string to examine
4597 ...         $szEnd  (string)    the string to look for
4598 ...     *}
4599 ... 
4600 ...     {*return
4601 ...         (boolean)   true if $szStr ends with $szEnd
4602 ...     *}
4603 ... 
4604 ...     {*assert
4605 ...         STR_EndsWith( '.php=return (int) date( "d" );',';' ) === true
4606 ...     *}
4607 ... 
4608 ...     {*assert
4609 ...         STR_EndsWith( 'Bonjour','jour' ) === true
4610 ...     *}
4611 ... 
4612 ...     {*example
4613 ...         if ( ! STR_EndsWith( $szFile,'/' ) )
4614 ...         {
4615 ...             $szFile .= '/';
4616 ...         }
4617 ...     *}
4618 ... 
4619 ...     {*seealso
4620 ...         STR_Right(),STR_StartsWith()
4621 ...     *}
4622 ... 
4623 ...     {*alias
4624 ...         STR_EndWith()
4625 ...     *}
4626 ... 
4627 ...     *}}
4628 ...  */
4629 ... /* ========================================================================== */
4630 ... function STR_EndsWith( $szStr,$szEnd )
4631 ... /*---------------------------------*/
4632 ... {
4633 ...     $bRetVal = false;                                               /* Return value of the function */
4634 ...     $iLength = strlen( $szEnd );                                    /* Length of $szEnd */
4635 ... 
4636 ...     if ( ! STR_Empty( $szStr ) && ( $iLength > 0 ) )                /* If all seems to be OK */
4637 ...     {
4638 ...         $bRetVal = ( STR_Right( $szStr,$iLength ) === $szEnd );     /* Compare strings */
4639 ...     }   /* if ( ! STR_Empty( $szStr ) && ( $iLength > 0 ) ) */
4640 ... 
4641 ...     return ( $bRetVal );                                            /* Return result to caller */
4642 ... } /* End of function STR_EndsWith() ========================================= */
4643 ... function STR_EndWith( $szStr,$szStart ) { return ( STR_EndsWith( $szStr,$szStart ) ); }
4644 ... 
4645 ... /* ========================================================================== */
4646 ... /** {{*STR_Replicate( $szStr,$iTimes )=
4647 ... 
4648 ...     Replicates a string
4649 ... 
4650 ...     {*params
4651 ...         $szStr      (string)    the string to be repeated
4652 ...         $iTimes     (int)       number of times to repeat $szStr
4653 ...     *}
4654 ... 
4655 ...     {*alias
4656 ...         STR_Copy()
4657 ...     *}
4658 ... 
4659 ...     {*remark
4660 ...         This is merely a wrapper around PHP built-in function [c]str_repeat()[/c].
4661 ...         The STR_Copy() alias defines the $iTimes parameter as [c]2[/c] by default.
4662 ...     *}
4663 ... 
4664 ...     {*return
4665 ...         (string)   resulting string
4666 ...     *}
4667 ... 
4668 ...     {*assert
4669 ...         STR_Replicate( 'me',3 ) === 'mememe'
4670 ...     *}
4671 ... 
4672 ...     {*assert
4673 ...         STR_Copy( 'copy-me' ) === 'copy-mecopy-me'
4674 ...     *}
4675 ... 
4676 ...     {*example
4677 ...         echo STR_Replicate( 'me',3 ); // Prints 'mememe'
4678 ...     *}
4679 ...     *}}
4680 ...  */
4681 ... /* ========================================================================== */
4682 ... function STR_Replicate( $szStr,$iTimes )
4683 ... /*------------------------------------*/
4684 ... {
4685 ...    return ( str_repeat( $szStr,$iTimes ) );
4686 ... }   /* End of function STR_Replicate() */
4687 ... function STR_copy( $szStr,$iTimes = 2 ) { return ( str_repeat( $szStr,$iTimes ) ); }
4688 ... 
4689 ... /* ========================================================================== */
4690 ... /** {{*STR_LastPos( $szStr,$szSubStr )=
4691 ... 
4692 ...     Finds the position of the last occurrence of a substring in a string
4693 ... 
4694 ...     {*params
4695 ...         $szStr      (string)    the string to be searched
4696 ...         $szSubStr   (string)    the substring to look for
4697 ...     *}
4698 ... 
4699 ...     {*return
4700 ...         (int)       -1 if $szSubStr not found in $szStr; otherwise it
4701 ...                     indicates the last position where $szSubStr is found
4702 ...                     in $szStr
4703 ...     *}
4704 ... 
4705 ...     {*assert
4706 ...         STR_LastPos( '/index.php;/Index.php','/' ) === 11
4707 ...     *}
4708 ... 
4709 ...     {*assert
4710 ...         STR_LastPos( '/index.php;/Index.php','Hello' ) === -1
4711 ...     *}
4712 ... 
4713 ...     {*assert
4714 ...         STR_LastPos( '/index.php','/' ) === 0
4715 ...     *}
4716 ... 
4717 ...     {*example
4718 ...         echo STR_LastPos( '/index.php;/Index.php','/' ); // Prints 11
4719 ...     *}
4720 ...     *}}
4721 ...  */
4722 ... /* ====================================================================== */
4723 ... function STR_LastPos( $szStr,$szSubStr )
4724 ... /*------------------------------------*/
4725 ... {
4726 ...     $iPos = strrpos( $szStr,$szSubStr );
4727 ...     return ( $iPos === false ? -1 : $iPos );
4728 ... }   /* End of function STR_LastPos() */
4729 ... /* ====================================================================== */
4730 ... 
4731 ... /* ====================================================================== */
4732 ... /** {{*STR_Last( $szStr,$iLength )=
4733 ... 
4734 ...     Determines the $iLength last characters of $szStr
4735 ... 
4736 ...     {*params
4737 ...         $szStr      (string)    String to process
4738 ...         $iLength    (int)       Optional length. [c]1[/c] by default.
4739 ...     *}
4740 ... 
4741 ...     {*return
4742 ...         (string)    The $iLength last characters of $szStr
4743 ...     *}
4744 ... 
4745 ...     {*assert
4746 ...         STR_LastPos( '/index.php;/Index.php','/' ) === 11
4747 ...     *}
4748 ... 
4749 ...     {*assert
4750 ...         STR_LastPos( '/index.php;/Index.php','Hello' ) === -1
4751 ...     *}
4752 ... 
4753 ...     {*assert
4754 ...         STR_LastPos( '/index.php','/' ) === 0
4755 ...     *}
4756 ... 
4757 ...     {*example
4758 ...         echo STR_LastPos( '/index.php;/Index.php','/' ); // Prints 11
4759 ...     *}
4760 ...     *}}
4761 ...  */
4762 ... /* ====================================================================== */
4763 ... function STR_Last( $szStr,$iLength = 1 )
4764 ... /*------------------------------------*/
4765 ... {
4766 ...     return ( substr( $szStr,-$iLength ) );
4767 ... }   /* End of function STR_Last() */
4768 ... /* ====================================================================== */
4769 ... 
4770 ... /* ====================================================================== */
4771 ... /** {{*STR_Pos( $szStr,$szSubStr[,$iStart] )=
4772 ... 
4773 ...     Finds the position of first occurrence of a string ([b]case sensitive[/b])
4774 ... 
4775 ...     {*params
4776 ...         $szStr      (string)    the string to be searched
4777 ...         $szSubStr   (string)    the substring to look for
4778 ...         $iStart     (int)       Optional offset parameter to specify where
4779 ...                                 searching must start. [c]0[/c] by default.
4780 ...     *}
4781 ... 
4782 ...     {*return
4783 ...         (int)       -1 if $szSubStr not found in $szStr; otherwise it
4784 ...                     indicates the 1st position where $szSubStr is found
4785 ...                     in $szStr
4786 ...     *}
4787 ... 
4788 ...     {*assert
4789 ...         STR_Pos( 'Hello','l' ) === 2
4790 ...     *}
4791 ... 
4792 ...     {*assert
4793 ...         STR_Pos( 'HeLlo','l' ) === 3
4794 ...     *}
4795 ... 
4796 ...     {*assert
4797 ...         STR_Pos( 'HeLlo','pa' ) === -1
4798 ...     *}
4799 ... 
4800 ...     {*example
4801 ...         echo STR_Pos( 'Hello World','d' ); // Prints 10
4802 ...     *}
4803 ... 
4804 ...     {*seealso
4805 ...         STR_iPos()
4806 ...     *}
4807 ... 
4808 ...     *}}
4809 ...  */
4810 ... /* ====================================================================== */
4811 ... function STR_Pos( $szStr,$szSubStr )
4812 ... /*--------------------------------*/
4813 ... {
4814 ...     if ( is_null( $szStr ) || is_null( $szSubStr ) || $szSubStr === '' || $szStr === '' )
4815 ...     {
4816 ...         return ( -1 );
4817 ...     }
4818 ...     else
4819 ...     {
4820 ...         $iPos = strpos( $szStr,$szSubStr );
4821 ...         return ( $iPos === false ? -1 : $iPos );
4822 ...     }
4823 ... }   /* End of function STR_Pos() */
4824 ... /* ====================================================================== */
4825 ... 
4826 ... /* ====================================================================== */
4827 ... /** {{*STR_iPos( $szStr,$szSubStr,$iStart )=
4828 ... 
4829 ...     Finds the position of first occurrence of a string ([b]case insensitive[/b])
4830 ... 
4831 ...     {*params
4832 ...         $szStr      (string)    String to be searched
4833 ...         $szSubStr   (string)    Substring to look for
4834 ...         $iStart     (int)       Optional offset parameter to specify where
4835 ...                                 searching must start. [c]0[/c] by default.
4836 ...     *}
4837 ... 
4838 ...     {*return
4839 ...         (int)       -1 if $szSubStr not found in $szStr; otherwise it
4840 ...                     indicates the 1st position where $szSubStr is found
4841 ...                     in $szStr
4842 ...     *}
4843 ... 
4844 ...     {*assert
4845 ...         STR_iPos( 'Hello','l' ) === 2
4846 ...     *}
4847 ... 
4848 ...     {*assert
4849 ...         STR_iPos( 'HeLlo','l' ) === 2
4850 ...     *}
4851 ... 
4852 ...     {*assert
4853 ...         STR_iPos( 'HeLlo','l',3 ) === 3
4854 ...     *}
4855 ... 
4856 ...     {*assert
4857 ...         STR_iPos( 'HeLlo','pa' ) === -1
4858 ...     *}
4859 ... 
4860 ...     {*assert
4861 ...          STR_iPos( 'C:/websites/latosensu.be/www/httpdocs/georama','C:/websites/latosensu.be/www/httpdocs' ) !== -1
4862 ...     *}
4863 ... 
4864 ...     {*example
4865 ...         echo STR_iPos( '/index.php;/Index.php','/' ); // Prints 0
4866 ...     *}
4867 ... 
4868 ...     {*seealso
4869 ...         STR_Pos()
4870 ...     *}
4871 ... 
4872 ...     *}}
4873 ...  */
4874 ... /* ========================================================================== */
4875 ... function STR_iPos( $szStr,$szSubStr,$iStart = 0 )
4876 ... /*---------------------------------------------*/
4877 ... {
4878 ...     $iPos = stripos( $szStr,$szSubStr,$iStart );
4879 ...     return ( $iPos === false ? -1 : $iPos );
4880 ... }   /* End of function STR_iPos() =========================================== */
4881 ... 
4882 ... /* ========================================================================== */
4883 ... /** {{*STR_Reduce( $szStr,$cChar )=
4884 ... 
4885 ...     Reduces consecutive occurrences of the same character to only 1 occurrence
4886 ... 
4887 ...     {*params
4888 ...         $szStr      (string)    string to process
4889 ...         $cChar      (char)      character to reduce to 1 consecutive occurrence.
4890 ...                                 Optional. [c]' '[/c] by default.
4891 ...     *}
4892 ... 
4893 ...     {*return
4894 ...         (string)   resulting string
4895 ...     *}
4896 ... 
4897 ...     {*assert
4898 ...         trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) === "Hello Hello Hello Hello Hello"
4899 ...     *}
4900 ... 
4901 ...     {*assert
4902 ...         STR_Reduce( "Hello",'l' ) === "Helo"
4903 ...     *}
4904 ... 
4905 ...     {*assert
4906 ...         STR_Reduce( "c://somedir//somefolder//hello.txt",'/' ) === "c:/somedir/somefolder/hello.txt"
4907 ...     *}
4908 ... 
4909 ...     {*example
4910 ...         echo '"' . trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) . '"';
4911 ...     *}
4912 ... 
4913 ...     {*seealso
4914 ...         STR_Replicate(), STR_Reduce2()
4915 ...     *}
4916 ...     *}}
4917 ...  */
4918 ... /* ========================================================================== */
4919 ... function STR_Reduce( $szStr,$cChar = ' ' )
4920 ... /*--------------------------------------*/
4921 ... {
4922 ...     $szRetVal = '';                                                 /* Return value of the function */
4923 ... 
4924 ...     if ( ! STR_Empty( $szStr ) && ! STR_Empty( $cChar ) )           /* If strings not empty */
4925 ...     {
4926 ...         $cChar = $cChar[0];
4927 ... 
4928 ...         if ( $cChar === '/' )
4929 ...         {
4930 ...             $cToSearch = '\/';
4931 ...         }
4932 ...         else
4933 ...         {
4934 ...             $cToSearch = quotemeta( $cChar );                       /* Treat 1st char only */
4935 ...         }
4936 ...         $szRetVal   = preg_replace( "/{$cToSearch}{2,}/s",$cChar,$szStr );
4937 ... 
4938 ...     }   /* if ( ! STR_Empty( $szStr ) && ! STR_Empty( $cChar ) ) */
4939 ... 
4940 ...     return ( $szRetVal );                                           /* Return result to caller */
4941 ... }   /* End of function STR_Reduce() ========================================= */
4942 ... 
4943 ... /* ========================================================================== */
4944 ... /** {{*STR_Reduce2( $szStr )=
4945 ... 
4946 ...     Reduces consecutive occurrences of the same character to only 1 occurrence
4947 ... 
4948 ...     {*params
4949 ...         $szStr      (string)    string to process
4950 ...     *}
4951 ... 
4952 ...     {*return
4953 ...         (string)   resulting string
4954 ...     *}
4955 ... 
4956 ...     {*assert
4957 ...         trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) === "Hello Hello Hello Hello Hello"
4958 ...     *}
4959 ... 
4960 ...     {*assert
4961 ...         STR_Reduce( "Hello",'l' ) === "Helo"
4962 ...     *}
4963 ... 
4964 ...     {*assert
4965 ...         STR_Reduce( "c://somedir//somefolder//hello.txt",'/' ) === "c:/somedir/somefolder/hello.txt"
4966 ...     *}
4967 ... 
4968 ...     {*example
4969 ...         echo '"' . trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) . '"';
4970 ...     *}
4971 ... 
4972 ...     {*seealso
4973 ...         STR_Replicate(), STR_Reduce2()
4974 ...     *}
4975 ...     *}}
4976 ...  */
4977 ... /* ========================================================================== */
4978 ... function STR_Reduce2( $szStr )
4979 ... /*--------------------------*/
4980 ... {
4981 ...     $szRetVal = '';                                                 /* Return value of the function */
4982 ...     $cPrev = '';
4983 ... 
4984 ...     if ( ! STR_Empty( $szStr ) )           /* If strings not empty */
4985 ...     {
4986 ...         $szStr = mb_convert_encoding( trim( $szStr ),'Windows-1252' );
4987 ... 
4988 ...         $iLen = strlen( $szStr );
4989 ... 
4990 ...         for ( $i = 0; $i < $iLen; $i++ )
4991 ...         {
4992 ...             if ( ( $c = $szStr[$i] ) != $cPrev )
4993 ...             {
4994 ...                 $szRetVal .= $c;
4995 ...             }
4996 ...         }   /* for ( $i = 0; $i < $iLen; $i++ ) */
4997 ...     }   /* if ( ! STR_Empty( $szStr ) && ! STR_Empty( $cChar ) ) */
4998 ... 
4999 ...     return ( mb_convert_encoding( $szRetVal,'UTF-8','Windows-1252' ) ); /* Return result to caller */
5000 ... }   /* End of function STR_Reduce2() ======================================== */
5001 ... 
5002 ... function STR_hash( $szWord )
5003 ... /*------------------------*/
5004 ... {
5005 ...     // Eliminate all accents (Windows-1252)
5006 ...     return( STR_Sort( strtoupper( preg_replace('/[\x41\x45\x49\x4F\x55\x59\x61\x65\x69\x6F\x75\x79\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD2\xD3\xD4\xD5\xD6\xD9\xDA\xDB\xDC\xDD\xE0\xE1\xE2\xE3\xE4\xE5\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF2\xF3\xF4\xF5\xF6\xF9\xFA\xFB\xFC\xFD\xFF]|[[:punct:]]/sim','',STR_stripAccents( $szWord ) ) ) ) );
5007 ... }
5008 ... 
5009 ... /* ========================================================================== */
5010 ... /** {{*STR_UnEntities( $szStr )=
5011 ... 
5012 ...     Transforms all HTML entities into their equivalent characters
5013 ... 
5014 ...     {*params
5015 ...         $szStr  (string)    Input string
5016 ...     *}
5017 ... 
5018 ...     {*return
5019 ...         (string)    All HTML entities turned to their equivalent characters
5020 ...                     (e.g. '&eacute;' is turned to 'é')
5021 ...     *}
5022 ... 
5023 ...     {*chist 09/02/2013
5024 ...     *}
5025 ... 
5026 ...     {*example
5027 ...         echo STR_UnEntities( 'Pr&eacute;sident' );    // Prints 'Président'
5028 ...     *}
5029 ... 
5030 ...     {*alias
5031 ...         unhtmlentities()
5032 ...     *}
5033 ... 
5034 ...     *}}
5035 ...  */
5036 ... /* ========================================================================== */
5037 ... function STR_UnEntities( $szStr,$szCharset = 'ISO-8859-1' )
5038 ... /*-------------------------------------------------------*/
5039 ... {
5040 ...     /* Way #1 of doing it myself */
5041 ...     // replace numeric entities
5042 ...     //$szStr = preg_replace( '~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))',$szStr );
5043 ...     //$szStr = preg_replace( '~&#([0-9]+);~e'     , 'chr("\\1")'        ,$szStr );
5044 ...     //
5045 ...     //// replace literal entities
5046 ...     //$trans_tbl = get_html_translation_table(HTML_ENTITIES);
5047 ...     //$trans_tbl = array_flip($trans_tbl);
5048 ...     //
5049 ...     //return ( strtr( $szStr,$trans_tbl ) );
5050 ... 
5051 ...     /* Way #2 of doing it myself */
5052 ...     //return ( str_replace( array( '&ocirc;'   ,'&eacute;'  ,'&ecirc;'  ,'&egrave;' ,'&agrave'  ,'&laquo;'  ,'&raquo;'  ,'&#8249;'  ,'&lsaquo;' ,'&#8250;'  ,'&rsaquo;' ),
5053 ...     //                      array( '�'         ,'é'         ,'ê'        ,'Ú'        ,'à'        ,'«'        ,'»'        ,'<'        ,'<'        ,'>'        ,'>'        ),
5054 ...     //                      $szStr ) );
5055 ... 
5056 ...     return ( html_entity_decode( $szStr,ENT_COMPAT,$szCharset ) );
5057 ... }   /* End of function STR_UnEntities() */
5058 ... /* ====================================================================== */
5059 ... function unhtmlentities( $szStr,$szCharset = 'ISO-8859-15' ) { return ( STR_UnEntities( $szStr,$szCharset ) ); }
5060 ... 
5061 ... /* ====================================================================== */
5062 ... /** {{*STR_Balance( $szStr,$szStart,$szEnd )=
5063 ... 
5064 ...     Returns the portion of string that balances $szStart with $szEnd
5065 ... 
5066 ...     {*params
5067 ...         $szStr      (string)    Input string
5068 ...         $szStart    (string)    Start of string pattern
5069 ...         $szEnd      (string)    End of string pattern
5070 ...     *}
5071 ... 
5072 ...     {*return
5073 ...         (string)    The string portion including $szStart and comprising $szEnd;
5074 ...                     null if no match found.
5075 ...     *}
5076 ... 
5077 ...     {*exec
5078 ...         $szStr = '<div id="footer">' .
5079 ...                      '<address>Rue Bois des Mazuis, 47 - 5070 - Vitrival' .
5080 ...                          '<div class="org">Lato Sensu Management</div>' .
5081 ...                      '</address>' .
5082 ...                  '</div><div><ol><li>Option 1</li><li>Option 2</li></ol></div>';
5083 ... 
5084 ...         echo '<p style="border-bottom:1px solid #000;">Original string</p>';
5085 ...         echo $szStr;
5086 ... 
5087 ...         echo '<p style="border-bottom:1px solid #000;">Footer div (balanced)</p>';
5088 ...         echo STR_Balance( $szStr,'<div','</div>' );
5089 ...     *}
5090 ... 
5091 ...     {*assert
5092 ...         STR_Balance( '<div id="myDiv"><h2>My title</h2><p>Hello</p></div>','<p>','</p>' ) === '<p>Hello</p>'
5093 ...     *}
5094 ... 
5095 ...     *}}
5096 ...  */
5097 ... /* ====================================================================== */
5098 ... function STR_Balance( $szStr,$szStart,$szEnd )
5099 ... /*------------------------------------------*/
5100 ... {
5101 ...     $szRetVal = null;                                               /* Default return value of the function */
5102 ... 
5103 ...     /* First examine whether we can indeed find the start and end words */
5104 ...     if ( strlen( $szStart ) > 0 && strlen( $szEnd ) > 0   &&
5105 ...          ( ( $szStr = strstr( $szStr,$szStart ) ) != false ) &&
5106 ...            (          strstr( $szStr,$szEnd   )   != false ) )
5107 ...     {
5108 ...         $iLength    = strlen( $szStr );                             /* OK ... length of string to treat */
5109 ...         $szWord     = '';                                           /* Current word we're reading (or even phrase) */
5110 ...         $iMatch     = 0;                                            /* Match count */
5111 ... 
5112 ...         for ( $i = 0;$i < $iLength;$i++ )                           /* For the entire string */
5113 ...         {
5114 ...             $szWord .= $szStr[$i];                                  /* Word is appended with current char */
5115 ...             //echo "<p>{$i}: " . htmlentities( $szWord ) . " (match={$iMatch})</p>\n";
5116 ... 
5117 ...             if ( is_int( strpos( $szWord,$szStart ) ) )             /* If start pattern found */
5118 ...             {
5119 ...                 //echo "<p>START FOUND at {$i}. iMatch was '{$iMatch} and now becomes ";
5120 ...                 $iMatch++;                                          /* Increment match counter */
5121 ...                 //echo "'{$iMatch}'</p>\n";
5122 ...                 $szWord = '';                                       /* Reset current word */
5123 ...             }   /* if ( is_int( strpos( $szWord,$szStart ) ) ) */
5124 ...             elseif ( is_int( strpos( $szWord,$szEnd ) ) )           /* If end pattern found */
5125 ...             {
5126 ...                 //echo "<p>END FOUND at {$i}. iMatch valait '{$iMatch} et devient maintenant ";
5127 ...                 $iMatch--;                                          /* Decrement match counter */
5128 ...                 //echo "'{$iMatch}'</p>\n";
5129 ...                 $szWord = '';                                       /* Reset current word */
5130 ... 
5131 ...                 if ( $iMatch === 0 )                                /* If start pattern is balanced with end pattern */
5132 ...                 {
5133 ...                     //echo "<p>Balanced at {$i}</p>";
5134 ...                     $szRetVal = substr( $szStr,0,$i+1 );            /* Return string from beginning to current position (included) */
5135 ...                     break;                                          /* Stop here !!! */
5136 ...                 }   /* if ( $iMatch === 0 ) */
5137 ...             }
5138 ...         }   /* for ( $i = 0;$i < $iLength;$i++ ) */
5139 ...         //$szRetVal = $szStr;
5140 ...     }   /* if ( ( ( $szStr = strstr( $szStr,$szStart ) ) != false ) && ... */
5141 ... 
5142 ...     return ( $szRetVal );                                           /* Return result to caller */
5143 ... }   /* End of function STR_Balance() ======================================== */
5144 ... 
5145 ... /* ========================================================================== */
5146 ... /** {{*STR_Keep( $szStr,$szChars )=
5147 ... 
5148 ...     Keeps only the characters of $szStr which can be found in $szChars
5149 ... 
5150 ...     {*params
5151 ...         $szStr      (string)    Input string
5152 ...         $szChars    (string)    List of chars to keep
5153 ...     *}
5154 ... 
5155 ...     {*return
5156 ...         (string)    The resulting string
5157 ...     *}
5158 ... 
5159 ...     {*uses
5160 ...         STR_Pos()
5161 ...     *}
5162 ... 
5163 ...     {*assert
5164 ...         STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) === 'ueoieauiiia'
5165 ...     *}
5166 ... 
5167 ...     {*assert
5168 ...         STR_IsVowel( STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) )
5169 ...     *}
5170 ... 
5171 ...     {*exec
5172 ...         echo '<p>',STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ),'</p>';
5173 ...     *}
5174 ... 
5175 ...     {*seealso
5176 ...         STR_Eliminate()
5177 ...     *}
5178 ... 
5179 ...     *}}
5180 ...  */
5181 ... /* ========================================================================== */
5182 ... function STR_Keep( $szStr,$szChars )
5183 ... /*--------------------------------*/
5184 ... {
5185 ...     $szRetVal   = '';                                               /* Default return value of the function */
5186 ...     $iLength    = strlen( $szStr );                                 /* Length of the string to treat */
5187 ... 
5188 ...     for ( $i = 0;$i < $iLength;$i++ )                               /* For the entire string */
5189 ...     {
5190 ...         if ( STR_Pos( $szChars,$cChar = $szStr[$i] ) != -1 )        /* Char is appended if in $szChars */
5191 ...             $szRetVal .= $cChar;
5192 ...     }   /* for ( $i = 0;$i < $iLength;$i++ ) */
5193 ... 
5194 ...     return ( $szRetVal );                                           /* Return result to caller */
5195 ... }   /* End of function STR_Keep() =========================================== */
5196 ... 
5197 ... /* ========================================================================== */
5198 ... /** {{*STR_Vowels( $szStr,$szChars )=
5199 ... 
5200 ...     Keeps only the vowels of $szStr
5201 ... 
5202 ...     {*params
5203 ...         $szStr      (string)    Input string
5204 ...         $szChars    (string)    List of chars to keep. Optional.
5205 ...     *}
5206 ... 
5207 ...     {*return
5208 ...         (string)    The resulting string (only the vowels).
5209 ...     *}
5210 ... 
5211 ...     {*assert
5212 ...         STR_Vowels( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) === 'ueoieauiiia'
5213 ...     *}
5214 ... 
5215 ...     {*exec
5216 ...         echo STR_Vowels( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ); // Prints 'ueoieauiiia'
5217 ...     *}
5218 ...     *}}
5219 ...  */
5220 ... /* ========================================================================== */
5221 ... function STR_Vowels( $szStr,$szChars = 'aeiouyAEIOUY')
5222 ... /*--------------------------------------------------*/
5223 ... {
5224 ...     return ( STR_Keep( $szStr,$szChars ) );                         /* Return result to caller */
5225 ... }   /* End of function STR_Vowels() ========================================= */
5226 ... 
5227 ... /* ========================================================================== */
5228 ... /** {{*STR_Strin( $szStr,$iRid )=
5229 ... 
5230 ...     Returns $szStr amputated from the last character
5231 ... 
5232 ...     {*params
5233 ...         $szStr      (string)    Input string
5234 ...         $iRid       (int)       Number of characters to amputate $szStr from.
5235 ...                                 Optional. 1 by default
5236 ...     *}
5237 ... 
5238 ...     {*return
5239 ...         (string)    The resulting string (length - $iRid characters).
5240 ...     *}
5241 ... 
5242 ...     {*assert
5243 ...         STR_Strin( 'Hello' ) === 'Hell'
5244 ...     *}
5245 ... 
5246 ...     {*assert
5247 ...         STR_Strin( 'Hello',2 ) === 'Hel'
5248 ...     *}
5249 ... 
5250 ...     {*example
5251 ...         $szFields =
5252 ...         $szValues = '';
5253 ... 
5254 ...         foreach( $aFields as $szField => $szValue )  // For each field
5255 ...         {
5256 ...             $szFields   .= trim( $szField ) . ',';
5257 ...             $szValues   .= trim( $szValue ) . ',';
5258 ...         }
5259 ... 
5260 ...         $szFields = STR_Strin( $szFields );
5261 ...         $szValues = STR_Strin( $szValues );
5262 ...     *}
5263 ...     *}}
5264 ...  */
5265 ... /* ========================================================================== */
5266 ... function STR_Strin( $szStr,$iRid = 1 )
5267 ... /*----------------------------------*/
5268 ... {
5269 ...     if ( ! STR_Empty( $szStr ) && $iRid > 0 )                       /* If string NOT empty and valid $iRid */
5270 ...     {
5271 ...         return ( substr( $szStr,0,-$iRid ) );                       /* Return string -iRid chars */
5272 ...     }
5273 ...     else
5274 ...     {
5275 ...         return ( $szStr );                                          /* Return result to caller (original string) */
5276 ...     }
5277 ... }   /* End of function STR_Strin() ========================================== */
5278 ... 
5279 ... /* ========================================================================== */
5280 ... /** {{*STR_AddSlash( $szStr,$szChar )=
5281 ... 
5282 ...     Adds a slash to $szStr only if rightmost character of $szStr is not a
5283 ...     slash ($szChar, defaulted to [c]'/'[/c]).
5284 ... 
5285 ...     {*params
5286 ...         $szStr      (string)    Input string
5287 ...         $szChar     (char)      Slash character. Optional. [c]'/'[/c] by default.
5288 ...     *}
5289 ... 
5290 ...     {*warning       $szChar should be a single character for the function to
5291 ...                     work as expected and documented. Make sure you do not
5292 ...                     pass an empty string ($szStr )
5293 ...     *}
5294 ... 
5295 ...     {*return
5296 ...         (string)    The resulting string
5297 ...     *}
5298 ... 
5299 ...     {*assert
5300 ...         STR_AddSlash( 'http://www.latosensu.be/' ) === 'http://www.latosensu.be/'
5301 ...     *}
5302 ... 
5303 ...     {*assert
5304 ...         STR_AddSlash( 'http://www.latosensu.be' ) === 'http://www.latosensu.be/'
5305 ...     *}
5306 ... 
5307 ...     {*assert
5308 ...         STR_AddSlash( 'http://www.latosensu.be','\\' ) === 'http://www.latosensu.be\\'
5309 ...     *}
5310 ... 
5311 ...     {*example
5312 ...         $szURL = 'http://www.latosensu.be/articles';
5313 ...         echo STR_AddSlash( $szURL ) . 'core/php/strings.php'; // Prints 'http://www.latosensu.be/articles/core/php/strings.php'
5314 ...     *}
5315 ...     *}}
5316 ...  */
5317 ... /* ========================================================================== */
5318 ... function STR_AddSlash( $szStr,$szChar = '/' )
5319 ... /*-----------------------------------------*/
5320 ... {
5321 ...     return ( ( STR_right( $szStr,1 ) === $szChar ) ?                 /* Return result to caller */
5322 ...                $szStr                             :
5323 ...              $szStr . $szChar );
5324 ... }   /* End of function STR_AddSlash() ======================================= */
5325 ... 
5326 ... /* ========================================================================== */
5327 ... /** {{*STR_RemoveStartingSlash( $szStr,$szChar )=
5328 ... 
5329 ...     Removes starting slash from $szStr only if leftmost character of $szStr
5330 ...     is a slash ($szChar, defaulted to '/').
5331 ... 
5332 ...     {*params
5333 ...         $szStr      (string)    Input string
5334 ...         $szChar     (char)      Slash character. Optional. '/' by default.
5335 ...     *}
5336 ... 
5337 ...     {*warning       $szChar should be a single character for the function to
5338 ...                     work as expected and documented. Make sure you do not
5339 ...                     pass an empty string ($szStr )
5340 ...     *}
5341 ... 
5342 ...     {*return
5343 ...         (string)    The resulting string
5344 ...     *}
5345 ... 
5346 ...     {*assert
5347 ...         STR_RemoveStartingSlash( '/sitemap.php' ) === 'sitemap.php'
5348 ...     *}
5349 ... 
5350 ...     {*assert
5351 ...         STR_RemoveStartingSlash( 'sitemap.php' ) === 'sitemap.php'
5352 ...     *}
5353 ... 
5354 ...     {*assert
5355 ...         STR_RemoveStartingSlash( 'sitemap.php','s' ) === 'itemap.php'
5356 ...     *}
5357 ... 
5358 ...     {*example
5359 ...         // Example #1
5360 ...         $szBase = 'http://www.latosensu.be/articles/';
5361 ...         $szURL  = '/core/php/strings.php';
5362 ...         echo STR_AddSlash( $szBase ) . STR_RemovesStartingSlash( $szURL );
5363 ...         // Prints 'http://www.latosensu.be/articles/core/php/strings.php'
5364 ... 
5365 ...         // Example #2
5366 ...         $szBase = 'http://www.latosensu.be/articles';
5367 ...         $szURL  = 'core/php/strings.php';
5368 ...         echo STR_AddSlash( $szBase ) . STR_RemovesStartingSlash( $szURL );
5369 ...         // Prints 'http://www.latosensu.be/articles/core/php/strings.php'
5370 ... 
5371 ...     *}
5372 ...     *}}
5373 ...  */
5374 ... /* ========================================================================== */
5375 ... function STR_RemoveStartingSlash( $szStr,$szChar = '/' )
5376 ... /*----------------------------------------------------*/
5377 ... {
5378 ...     //echo "<p>{$szStr}</p>";
5379 ...     return ( ( STR_left( $szStr,1 ) === $szChar ) ?                 /* Return result to caller */
5380 ...                substr( $szStr,1 )                :
5381 ...              $szStr );
5382 ... }   /* End of function STR_RemovesStartingSlash() =========================== */
5383 ... 
5384 ... /* ========================================================================== */
5385 ... /** {{*STR_iInList( $aList,$szValue[,$bPartOf] )=
5386 ... 
5387 ...     Determines whether $szValue can be found in a list of possible values ($aList)
5388 ...     ([b]case insensitive[/b])
5389 ... 
5390 ...     {*params
5391 ...         $aList      (array)     Array of values
5392 ...         $szValue    (string)    The value to look for in $aList
5393 ...         $bPartOf    (boolean)   Optional. [c]false[/c] by default. If [c]true[/c]
5394 ...                                 a partial match is accepted.
5395 ...     *}
5396 ... 
5397 ...     {*remark
5398 ...         Case insensitive search
5399 ...     *}
5400 ... 
5401 ...     {*return
5402 ...         (bool)  [c]true[/c] if $szValue found in $aList; [c]false[/c] otherwise
5403 ...     *}
5404 ... 
5405 ...     {*assert
5406 ...         STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'/sitemap.php' ) === true
5407 ...     *}
5408 ... 
5409 ...     {*assert
5410 ...         STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'/SITEMAP.PHP' ) === true
5411 ...     *}
5412 ... 
5413 ...     {*assert
5414 ...         STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'map.php' ) === false
5415 ...     *}
5416 ... 
5417 ...     {*assert
5418 ...         STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'MAP.PHP' ) === false
5419 ...     *}
5420 ... 
5421 ...     {*assert
5422 ...         STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'.php',true ) === true
5423 ...     *}
5424 ... 
5425 ...     {*seealso
5426 ...         STR_InList()
5427 ...     *}
5428 ... 
5429 ...     {*example
5430 ...         if ( STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),$szPage ) )
5431 ...         {
5432 ...             echo "<p>{$szPage} found in list!</p>\n";
5433 ...         }
5434 ...     *}
5435 ...     *}}
5436 ...  */
5437 ... /* ========================================================================== */
5438 ... function STR_iInList( $aList,$szValue,$bPartOf = false )
5439 ... /*----------------------------------------------------*/
5440 ... {
5441 ...     $bRetVal = false;                                               /* Return value of the function */
5442 ... 
5443 ...     $szValue = strtolower( $szValue );                              /* Turn the thing to lowercase because it's a case insensitive search */
5444 ... 
5445 ...     foreach( $aList as $x )                                         /* For each slot of the array */
5446 ...     {
5447 ...         if ( is_string( $x ) )                                      /* If string */
5448 ...         {
5449 ...             if ( ! $bPartOf )                                       /* If perfect match */
5450 ...             {
5451 ...                 if ( $bRetVal = ( strtolower( $x ) === $szValue ) ) /* If result OK */
5452 ...                 {
5453 ...                     break;                                          /* Stop here */
5454 ...                 }
5455 ...             }
5456 ...             else
5457 ...             {
5458 ...                 if ( $bRetVal = ( STR_iPos( $x,$szValue ) !== -1 ) ) /* If result OK */
5459 ...                 {
5460 ...                     break;                                          /* Stop here */
5461 ...                 }
5462 ...             }
5463 ...         }   /* if ( is_string( $x ) ) */
5464 ...     }   /* foreach( $aList as $x ) */
5465 ... 
5466 ...     return ( $bRetVal );                                            /* Return result to caller */
5467 ... }   /* == End of function STR_InList() ====================================== */
5468 ... 
5469 ... /* ========================================================================== */
5470 ... /** {{*STR_InList( $aList,$szValue[,$bPartOf] )=
5471 ... 
5472 ...     Determines whether $szValue can be found in a list of possible values ($aList)
5473 ...     ([b]case sensitive[/b])
5474 ... 
5475 ...     {*params
5476 ...         $aList      (array)     Array of values
5477 ...         $szValue    (string)    The value to look for in $aList
5478 ...         $bPartOf    (boolean)   Optional. [c]false[/c] by default. If [c]true[/c]
5479 ...                                 a partial match is accepted.
5480 ...     *}
5481 ... 
5482 ...     {*remark
5483 ...         Case sensitive search
5484 ...     *}
5485 ... 
5486 ...     {*return
5487 ...         (bool)  true if $szValue found in $aList; false otherwise
5488 ...     *}
5489 ... 
5490 ...     {*assert
5491 ...         STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'/sitemap.php' ) === true
5492 ...     *}
5493 ... 
5494 ...     {*assert
5495 ...         STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'/SITEMAP.PHP' ) === false
5496 ...     *}
5497 ... 
5498 ...     {*assert
5499 ...         STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'map.php' ) === false
5500 ...     *}
5501 ... 
5502 ...     {*assert
5503 ...         STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'MAP.PHP' ) === false
5504 ...     *}
5505 ... 
5506 ...     {*assert
5507 ...         STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'legal',true ) === true
5508 ...     *}
5509 ... 
5510 ...     {*seealso
5511 ...         STR_iInList()
5512 ...     *}
5513 ... 
5514 ...     {*example
5515 ...         if ( STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),$szPage ) )
5516 ...         {
5517 ...             echo "<p>{$szPage} found in list!</p>\n";
5518 ...         }
5519 ...     *}
5520 ... 
5521 ...     *}}
5522 ...  */
5523 ... /* ========================================================================== */
5524 ... function STR_InList( $aList,$szValue,$bPartOf = false )
5525 ... /*---------------------------------------------------*/
5526 ... {
5527 ...     $bRetVal = false;                                               /* Return value of the function */
5528 ... 
5529 ...     foreach( $aList as $x )                                         /* For each slot of the array */
5530 ...     {
5531 ...         if ( is_string( $x ) )                                      /* If string */
5532 ...         {
5533 ...             if ( ! $bPartOf )                                       /* If perfect match */
5534 ...             {
5535 ...                 if ( $bRetVal = ( $x === $szValue ) )               /* If result OK */
5536 ...                 {
5537 ...                     break;                                          /* Stop here */
5538 ...                 }
5539 ...             }
5540 ...             else
5541 ...             {
5542 ...                 if ( $bRetVal = ( STR_iPos( strtolower( $x ),$szValue ) !== -1 ) ) /* If result OK */
5543 ...                 {
5544 ...                     break;                                          /* Stop here */
5545 ...                 }
5546 ...             }
5547 ...         }   /* if ( is_string( $x ) ) */
5548 ...     }   /* foreach( $aList as $x ) */
5549 ... 
5550 ...     return ( $bRetVal );                                            /* Return result to caller */
5551 ... }   /* == End of function STR_InList() ====================================== */
5552 ... 
5553 ... /* ========================================================================== */
5554 ... /** {{*STR_IsVowel( $cChar )=
5555 ... 
5556 ...     Determines whether the first character of $cChar is a vowel
5557 ... 
5558 ...     {*params
5559 ...         $cChar      (string)    The string whose 1st character is to be checked
5560 ...     *}
5561 ... 
5562 ...     {*return
5563 ...         (bool)  [c]true[/c] if [c]$cChar[0][/c] is a vowel; [c]false[/c] otherwise
5564 ...     *}
5565 ... 
5566 ...     {*assert
5567 ...         STR_IsVowel( 'Hello' ) === false
5568 ...     *}
5569 ... 
5570 ...     {*assert
5571 ...         STR_IsVowel( 'admittance' ) === true
5572 ...     *}
5573 ... 
5574 ...     {*assert
5575 ...         STR_IsVowel( 'Ã? demain' ) === true
5576 ...     *}
5577 ... 
5578 ...     {*seealso
5579 ...         STR_IsConsonant()
5580 ...     *}
5581 ... 
5582 ...     *}}
5583 ...  */
5584 ... /* ========================================================================== */
5585 ... function STR_IsVowel( $cChar )
5586 ... /*--------------------------*/
5587 ... {
5588 ...     return ( STR_Pos( "aeiouyàáâãÀåÊÚéêëìíîïÃ?òóÃ?õöùúûÌÿÜÃ?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Ã?Å?Ã?",substr( $cChar,0,1 ) ) != -1 );
5589 ... }   /* End of STR_IsVowel() ================================================= */
5590 ... 
5591 ... /* ========================================================================== */
5592 ... /** {{*STR_IsConsonant( $cChar )=
5593 ... 
5594 ...     Determines whether the first character of $cChar is a consonant
5595 ... 
5596 ...     {*params
5597 ...         $cChar      (string)    The string whose 1st character is to be checked
5598 ...     *}
5599 ... 
5600 ...     {*return
5601 ...         (bool)  [c]true[/c] if [c]$cChar[0][/c] is a consonant; [c]false[/c] otherwise
5602 ...     *}
5603 ... 
5604 ...     {*assert
5605 ...         STR_IsConsonant( 'Hello' ) === true
5606 ...     *}
5607 ... 
5608 ...     {*assert
5609 ...         STR_IsConsonant( 'admittance' ) === false
5610 ...     *}
5611 ... 
5612 ...     {*seealso
5613 ...         STR_IsVowel()
5614 ...     *}
5615 ... 
5616 ...     *}}
5617 ...  */
5618 ... /* ========================================================================== */
5619 ... function STR_IsConsonant( $cChar )
5620 ... /*------------------------------*/
5621 ... {
5622 ...     return ( STR_iPos( "bcdfghjklmnpqrstvwxz���çñ",substr( $cChar,0,1 ) ) != -1 );
5623 ... }   /* End of STR_IsConsonant() ============================================= */
5624 ... 
5625 ... /* ========================================================================== */
5626 ... /** {{*STR_SingularToPlural( $szWord,$szLang )=
5627 ... 
5628 ...     Get the plural form of a word
5629 ... 
5630 ...     {*params
5631 ...         $szWord     (string)    The word to obtain the plural form of
5632 ...         $szLang     (string)    Optional language. [c]fr[/c] by default.
5633 ...     *}
5634 ... 
5635 ...     {*return
5636 ...         (string)    Plural form of $szWord
5637 ...     *}
5638 ... 
5639 ...     {*warning
5640 ...         This function is experimental. Do not use in production environments.
5641 ...         Moreover, it only codes the plurals to singulars in French.
5642 ...     *}
5643 ... 
5644 ...     {*assert
5645 ...         STR_SingularToPlural( 'bureau' ) === 'bureaux'
5646 ...     *}
5647 ... 
5648 ...     {*assert
5649 ...         STR_SingularToPlural( 'flûtiau' ) === 'flûtiaux'
5650 ...     *}
5651 ... 
5652 ...     {*assert
5653 ...         STR_SingularToPlural( 'eau' ) === 'eaux'
5654 ...     *}
5655 ... 
5656 ...     {*assert
5657 ...         STR_SingularToPlural( 'hibou' ) === 'hiboux'
5658 ...     *}
5659 ... 
5660 ...     {*assert
5661 ...         STR_SingularToPlural( 'éventail' ) === 'éventails'
5662 ...     *}
5663 ... 
5664 ...     {*assert
5665 ...         STR_SingularToPlural( 'travail' ) === 'travaux'
5666 ...     *}
5667 ... 
5668 ...     {*assert
5669 ...         STR_SingularToPlural( 'cheval' ) === 'chevaux'
5670 ...     *}
5671 ... 
5672 ...     {*seealso
5673 ...         STR_PluralToSingular()
5674 ...     *}
5675 ...     *}}
5676 ...  */
5677 ... /* ========================================================================== */
5678 ... function STR_SingularToPlural( $szWord,$szLang = 'fr' )
5679 ... /*---------------------------------------------------*/
5680 ... {
5681 ...     $szRetVal = $szWord;
5682 ... 
5683 ...     if ( preg_match('/(e?)au\z/si',$szWord ) )
5684 ...     {
5685 ...         // Les noms en "au" et "eau" forment le pluriel en "x"
5686 ...         // sauf : "landaus, sarraus".
5687 ...         if ( in_array( $szWord,array( 'landau','sarrau' ) ) )
5688 ...         {
5689 ...             $szRetVal .= 's';
5690 ...         }
5691 ...         else
5692 ...         {
5693 ...             $szRetVal = preg_replace('/(e?)au\z/si','\1aux',$szWord );
5694 ...         }
5695 ...     }
5696 ... 
5697 ...     if ( $szRetVal === $szWord )
5698 ...     {
5699 ...         // Les noms en "eu" forment le pluriel en "x"
5700 ...         // sauf "bleus et pneus"
5701 ...         if ( preg_match('/eu\z/si',$szWord ) )
5702 ...         {
5703 ...             /* Cas d'une exception ? */
5704 ...             if ( in_array( $szWord,array( 'bleu','pneu' ) ) )
5705 ...             {
5706 ...                 $szRetVal .= 's';
5707 ...             }
5708 ...             else
5709 ...             {
5710 ...                 $szRetVal = preg_replace('/eu\z/si','eux',$szWord );
5711 ...             }
5712 ...         }
5713 ...     }
5714 ... 
5715 ...     if ( $szRetVal === $szWord )
5716 ...     {
5717 ...         // Les noms en "ou" forment le pluriel en "s"
5718 ...         // sauf : "poux, hiboux, choux, joujoux, genoux, cailloux, bijoux".
5719 ...         if ( preg_match('/ou\z/si',$szWord ) )
5720 ...         {
5721 ...             /* Cas d'une exception ? */
5722 ...             if ( in_array( $szWord,array( 'pou','chou','hibou','genou','caillou','joujou','bijou' ) ) )
5723 ...             {
5724 ...                 $szRetVal = preg_replace('/ou\z/si','oux',$szWord );
5725 ...             }
5726 ...             else
5727 ...             {
5728 ...                 $szRetVal = preg_replace('/ou\z/si','ous',$szWord );
5729 ...             }
5730 ...         }
5731 ...     }
5732 ... 
5733 ...     if ( $szRetVal === $szWord )
5734 ...     {
5735 ...         // Les noms en "al" forment le pluriel en "aux" ...
5736 ...         // sauf quelques exception
5737 ...         if ( preg_match('/al\z/si',$szWord ) )
5738 ...         {
5739 ...             /* Cas d'une exception ? */
5740 ...             if ( in_array( $szWord,array( 'aval','bal','cal','carnaval','chacal','choral',
5741 ...                                           'cérémonial','festival','nopal','pal','régal',
5742 ...                                           'narval','récital' ) ) )
5743 ...             {
5744 ...                 $szRetVal .= 's';
5745 ...             }
5746 ...             else
5747 ...             {
5748 ...                 $szRetVal = preg_replace('/al\z/si','aux',$szWord );
5749 ...             }
5750 ...         }
5751 ...     }
5752 ... 
5753 ...     if ( $szRetVal === $szWord )
5754 ...     {
5755 ...         // Les noms en "ail" forment le pluriel en "ails" sauf quelques
5756 ...         // exceptions qui le font en "aux"
5757 ...         if ( preg_match('/ail\z/si',$szWord ) )
5758 ...         {
5759 ...             /* Cas d'une exception ? */
5760 ...             if ( in_array( $szWord,array( 'bail','corail','émail','gemmail','soupirail',
5761 ...                                           'travail','vantail','vitrail' ) ) )
5762 ...             {
5763 ...                 $szRetVal = preg_replace('/ail\z/si','aux',$szWord );
5764 ...             }
5765 ...             else
5766 ...             {
5767 ...                 $szRetVal = preg_replace('/ail\z/si','ails',$szWord );
5768 ...             }
5769 ...         }
5770 ...     }
5771 ... 
5772 ...     // Les noms qui au singulier se terminent par "z", "x", ou "s" ne
5773 ...     // changent pas au pluriel.
5774 ...     if ( preg_match('/(z|x|s)\z/si',$szWord ) )
5775 ...     {
5776 ...     }
5777 ...     else
5778 ...     {
5779 ...         if ( $szRetVal === $szWord )
5780 ...         {
5781 ...             $szRetVal = $szWord . 's';
5782 ...         }
5783 ...     }
5784 ... 
5785 ...     //Il y a également des pluriels irréguliers :
5786 ...     //Bétail forme au pluriel "bestiaux" ;
5787 ...     //Bétail a un pluriel bétails peu utilisé ;
5788 ...     //Le nom composé crédit-bail forme au pluriel "crédits-bails" ;
5789 ...     //Le pluriel corails est employé pour des objets fabriqués dans cette matiÚre, pour la partie rouge de la coquille Saint-Jacques, du homard ;
5790 ...     //Le pluriel travails se rapporte à l'instrument du maréchal-ferrant (en technologie, machines servant à immobiliser les chevaux ou les boeufs pour qu'on les ferre ou les soigne).
5791 ... 
5792 ...     return ( $szRetVal );
5793 ... }
5794 ... 
5795 ... /* ====================================================================== */
5796 ... /** {{*STR_PluralToSingular( $szWord,$szLang )=
5797 ... 
5798 ...     Get the singular form of a word
5799 ... 
5800 ...     {*params
5801 ...         $szWord     (string)    The word to obtain the singular form of
5802 ...         $szLang     (string)    Optional language. [c]fr[/c] by default.
5803 ...     *}
5804 ... 
5805 ...     {*return
5806 ...         (string)    Singular form of $szWord
5807 ...     *}
5808 ... 
5809 ...     {*warning
5810 ...         This function is experimental. Do not use in production environments.
5811 ...         Moreover, it only codes the plurals to singulars in French.
5812 ...     *}
5813 ... 
5814 ...     {*assert
5815 ...         STR_PluralToSingular( 'bureaux' ) === 'bureau'
5816 ...     *}
5817 ... 
5818 ...     {*assert
5819 ...         STR_PluralToSingular( 'eaux' ) === 'eau'
5820 ...     *}
5821 ... 
5822 ...     {*assert
5823 ...         STR_PluralToSingular( 'flûtiaux' ) === 'flûtiau'
5824 ...     *}
5825 ... 
5826 ...     {*assert
5827 ...         STR_PluralToSingular( 'dieux' ) === 'dieu'
5828 ...     *}
5829 ... 
5830 ...     {*assert
5831 ...         STR_PluralToSingular( 'feux' ) === 'feu'
5832 ...     *}
5833 ... 
5834 ...     {*assert
5835 ...         STR_PluralToSingular( 'trous' ) === 'trou'
5836 ...     *}
5837 ... 
5838 ...     {*assert
5839 ...         STR_PluralToSingular( 'demoiselle' ) === 'demoiselle'
5840 ...     *}
5841 ... 
5842 ...     {*assert
5843 ...         STR_PluralToSingular( 'chevaux' ) === 'cheval'
5844 ...     *}
5845 ... 
5846 ...     {*assert
5847 ...         STR_PluralToSingular( 'éventails' ) === 'éventail'
5848 ...     *}
5849 ... 
5850 ...     {*assert
5851 ...         STR_PluralToSingular( 'matiÚres' ) === 'matiÚre'
5852 ...     *}
5853 ... 
5854 ...     {*assert
5855 ...         STR_PluralToSingular( 'noms' ) === 'nom'
5856 ...     *}
5857 ... 
5858 ...     {*assert
5859 ...         STR_PluralToSingular( 'abstraits' ) === 'abstrait'
5860 ...     *}
5861 ... 
5862 ...     {*assert
5863 ...         STR_PluralToSingular( 'objets' ) === 'objet'
5864 ...     *}
5865 ... 
5866 ...     {*assert
5867 ...         STR_PluralToSingular( 'funérailles' ) === 'funéraille'
5868 ...     *}
5869 ... 
5870 ...     {*assert
5871 ...         STR_PluralToSingular( 'montagnes' ) === 'montagne'
5872 ...     *}
5873 ... 
5874 ...     {*assert
5875 ...         STR_PluralToSingular( 'avons' ) === 'avons'
5876 ...     *}
5877 ... 
5878 ...     {*assert
5879 ...         STR_PluralToSingular( 'enzymes' ) === 'enzyme'
5880 ...     *}
5881 ... 
5882 ...     {*assert
5883 ...         STR_PluralToSingular( 'enverrons' ) === 'enverrons'
5884 ...     *}
5885 ... 
5886 ...     {*assert
5887 ...         STR_PluralToSingular( 'envoyâmes' ) === 'envoyâmes'
5888 ...     *}
5889 ... 
5890 ...     {*assert
5891 ...         STR_PluralToSingular( 'envoyâtes' ) === 'envoyâtes'
5892 ...     *}
5893 ... 
5894 ...     {*assert
5895 ...         STR_PluralToSingular( 'enverras' ) === 'enverras'
5896 ...     *}
5897 ... 
5898 ...     {*assert
5899 ...         STR_PluralToSingular( 'envoyions' ) === 'envoyions'
5900 ...     *}
5901 ... 
5902 ...     {*assert
5903 ...         STR_PluralToSingular( 'ions' ) === 'ion'
5904 ...     *}
5905 ... 
5906 ...     {*assert
5907 ...         STR_PluralToSingular( 'avions' ) === 'avion'
5908 ...     *}
5909 ... 
5910 ... 
5911 ...     {*assert
5912 ...         STR_PluralToSingular( 'envoies' ) === 'envoies'
5913 ...     *}
5914 ... 
5915 ...     {*assert
5916 ...         STR_PluralToSingular( 'bijoux' ) === 'bijou'
5917 ...     *}
5918 ... 
5919 ...     {*assert
5920 ...         STR_PluralToSingular( 'cailloux' ) === 'caillou'
5921 ...     *}
5922 ... 
5923 ...     {*assert
5924 ...         STR_PluralToSingular( 'peux' ) === 'peux'
5925 ...     *}
5926 ... 
5927 ...     {*assert
5928 ...         STR_PluralToSingular( 'veux' ) === 'veux'
5929 ...     *}
5930 ... 
5931 ...     {*assert
5932 ...         STR_PluralToSingular( 'voeux' ) === 'voeu'
5933 ...     *}
5934 ... 
5935 ...     {*assert
5936 ...         STR_PluralToSingular( 'dix' ) === 'dix'
5937 ...     *}
5938 ... 
5939 ...     {*seealso
5940 ...         STR_SingularToPlural()
5941 ...     *}
5942 ... 
5943 ...     {*exec
5944 ...         echo '<p>',STR_PluralToSingular( 'flûtiaux' ),'</p>';
5945 ...     *}
5946 ...     *}}
5947 ...  */
5948 ... /* ========================================================================== */
5949 ... function STR_PluralToSingular( $szWord,$szLang = 'fr' )
5950 ... /*---------------------------------------------------*/
5951 ... {
5952 ...     $szRetVal = $szWord;
5953 ... 
5954 ...     // AILS - ALS - (E)AUX ************************************************** */
5955 ...     if ( $szRetVal === $szWord )
5956 ...     {
5957 ...         // Les noms en "ail" forment le pluriel en "s"
5958 ...         // sauf "baux, coraux, soupiraux, travaux, vantaux, vitraux"
5959 ...         if ( preg_match('/€?aux\z/si',$szWord ) )
5960 ...         {
5961 ...             // Si exception
5962 ...             if ( in_array( $szWord,array( 'baux','coraux','soupiraux','travaux','vantaux','vitraux' ) ) )
5963 ...             {
5964 ...                 $szRetVal = preg_replace('/aux\z/si','ail',$szWord );
5965 ...             }
5966 ...             else
5967 ...             {
5968 ...                 // Si 'eaux' en terminaison
5969 ...                 $szRetVal = preg_replace('/eaux\z/si','eau',$szWord );
5970 ... 
5971 ...                 if ( $szRetVal == $szWord )
5972 ...                 {
5973 ...                     // Si 'aux' en terminaison
5974 ...                     $szRetVal = preg_replace('/aux\z/si','al',$szWord );
5975 ...                 }
5976 ...             }
5977 ...             //if ( $szRetVal === $szWord )
5978 ...             //{
5979 ...             //    // Les noms en "au" et "eau" forment le pluriel en "x"
5980 ...             //    // Bon ... ici on a un souci
5981 ...             //    // La terminaison "[e]aux" peut venir de plusieurs singuliers
5982 ...             //    // possibles : des mots qui terminent par [e]au (ex: ruisseau)
5983 ...             //    //                                    par ail   (ex: vitrail)
5984 ...             //    //                                    par al    (ex: cheval)
5985 ...             //    if ( preg_match('/(e?)aux\z/si',$szWord ) )
5986 ...             //    {
5987 ...             //        $szRetVal = preg_replace('/(e?)aux\z/si','\1au',$szWord );
5988 ...             //    }
5989 ...             //}
5990 ...         }
5991 ...         elseif ( preg_match('/als\z/si',$szWord ) )
5992 ...         {
5993 ...             if ( in_array( $szWord,'avals','bals','cals','carnavals','chacals','chorals',
5994 ...                                    'cérémonials','festivals','nopals','pals','régals',
5995 ...                                    'narvals','récitals' ) )
5996 ...             {
5997 ...                 // Get rid of last char
5998 ...                 $szRetVal = STR_Strin( $szWord );
5999 ...             }
6000 ...         }
6001 ...     }
6002 ... 
6003 ...     // OUX et OUS *********************************************************** */
6004 ...     if ( $szRetVal === $szWord )
6005 ...     {
6006 ...         // Les noms en "oux" et "ous"
6007 ...         if ( preg_match( '/oux\z/si',$szWord ) )
6008 ...         {
6009 ...             if ( in_array( $szWord,array( 'bijoux','cailloux','choux','genoux','hiboux','joujoux','poux' ) ) )
6010 ...             {
6011 ...                 $szRetVal = STR_Strin( $szWord );
6012 ...             }
6013 ... 
6014 ...         }
6015 ...         elseif ( preg_match('/ous\z/si',$szWord ) )
6016 ...         {
6017 ...             $szRetVal = STR_Strin( $szWord );
6018 ...         }
6019 ... 
6020 ...     }
6021 ... 
6022 ...     // EUX et EUS *********************************************************** */
6023 ...     if ( $szRetVal === $szWord )
6024 ...     {
6025 ...         // Tous les mots qui terminent en '?eus' ou en '?eux'
6026 ...         // Les noms en "eu" forment le pluriel en "x" (Un feu, des feux. Un jeu, des jeux)
6027 ...         // sauf : "bleus, pneus".
6028 ...         if ( preg_match( '/[[:alpha:]]{1}?eu(s|x)\z/si',$szWord ) )
6029 ...         {
6030 ...             // On enlÚve le 'x' ou le 's'
6031 ...             $szRetVal = STR_Strin( $szWord );
6032 ...         }
6033 ...     }
6034 ... 
6035 ...     // Default cases ******************************************************** */
6036 ...     // Si la valeur de retour est inchangée, cela veut dire que nous
6037 ...     // n'avons pas encore trouvé le singulier
6038 ...     if ( $szRetVal === $szWord )
6039 ...     {
6040 ...         echo "<p>{$szWord}: je passe par le cas par défaut</p>\n";
6041 ...         if ( ( $iLen = strlen( $szWord ) ) > 2 )
6042 ...         {
6043 ...             // Cas de l'imparfait du subjonctif (1Úre et 2Úme personne du pluriel) */
6044 ...             if ( ! preg_match( '/[[:alpha:]]{1}?âm|tes\z/si',$szWord ) )
6045 ...             {
6046 ...                 // On enlÚve le dernier 'x' ou le dernier 's'
6047 ...                 $szRetVal = preg_replace('/x|s\z/si','',$szWord );
6048 ... 
6049 ...                 if ( $szRetVal == $szWord )
6050 ...                 {
6051 ...                     if ( STR_Right( $szWord,1 ) === 's' )
6052 ...                     {
6053 ...                       // Enlevons le dernier 's'
6054 ...                       $szRetVal = STR_Strin( $szWord );
6055 ...                     }
6056 ...                 }
6057 ...             }
6058 ...             // Attention, ici il y a un bug car si le mot est un mot
6059 ...             // qui se termine au singulier par par "z", "x", ou "s"
6060 ...             // ne changent pas au pluriel => il faudrait alors ne
6061 ...             // pas enlever le dernier caractÚre.
6062 ...         }
6063 ...     }
6064 ... 
6065 ...     return ( $szRetVal );
6066 ... }
6067 ... 
6068 ... //
6069 ... //    function __cliché( $szStr )
6070 ... //    {
6071 ... //        $iLen = strlen( $szStr );
6072 ... //
6073 ... //        // Un mot est toujours dans la forme [C](VC)m[V]
6074 ... //        // PremiÚre lettre du cliché
6075 ... //        $szRetVal = STR_IsConsonant( $szStr[0] ) ? 'C' : '';
6076 ... //        $cLast = $szRetVal;
6077 ... //
6078 ... //        for ( $i=1; $i < $iLen;$i++ )
6079 ... //        {
6080 ... //            if     ( STR_IsVowel( $szStr[$i] ) )
6081 ... //            {
6082 ... //                $cNew = 'V';
6083 ... //            }
6084 ... //            elseif ( STR_IsConsonant( $szStr[$i] ) )
6085 ... //            {
6086 ... //                $cNew = 'C';
6087 ... //            }
6088 ... //            else
6089 ... //            {
6090 ... //                $cNew = 'U';
6091 ... //            }
6092 ... //
6093 ... //            if ( $cNew !== $cLast )
6094 ... //            {
6095 ... //                $szRetVal .= $cNew;
6096 ... //            }
6097 ... //            $cLast = $cNew;
6098 ... //        }
6099 ... //
6100 ... //        $m = substr_count( $szRetVal,'VC' );
6101 ... //
6102 ... //        $szFinal = preg_replace( '/\A(C?)(VC){' . $m . '}(V?)\z/','\1(VC)' . $m . '\3',$szRetVal );
6103 ... //
6104 ... //        echo "<p>Le mot '{$szStr}' a comme cliché '{$szRetVal}' et comme stem '{$szFinal}'</p>\n";
6105 ... //
6106 ... //        return ( $szRetVal );
6107 ... //    }
6108 ... 
6109 ... /* ========================================================================== */
6110 ... /** {{*STR_IsDate( $szStr )=
6111 ... 
6112 ...     Determines whether $szStr respects the pattern of a date (YYYY?MM?DD)
6113 ... 
6114 ...     {*params
6115 ...         $szStr  (string)    The string to check for a date
6116 ...     *}
6117 ... 
6118 ...     {*return
6119 ...         (bool)  [c]true[/c] if $szStr seems to be a date
6120 ...     *}
6121 ... 
6122 ...     {*remark
6123 ...         Dates are checked against a YYYY MM DD pattern (year between 0000 and
6124 ...         5999)
6125 ...     *}
6126 ... 
6127 ...     {*assert
6128 ...         STR_IsDate( '1015.06.03' ) == true
6129 ...     *}
6130 ... 
6131 ...     {*assert
6132 ...         STR_IsDate( '2015.06 03' ) == true
6133 ...     *}
6134 ... 
6135 ...     {*assert
6136 ...         STR_IsDate( '5015 06 03' ) == true
6137 ...     *}
6138 ... 
6139 ...     {*assert
6140 ...         STR_IsDate( '6015 06 03' ) == false
6141 ...     *}
6142 ... 
6143 ...     {*assert
6144 ...         STR_IsDate( '2013/02/10' ) == true
6145 ...     *}
6146 ... 
6147 ...     {*assert
6148 ...         STR_IsDate( '2013-02-10' ) == true
6149 ...     *}
6150 ... 
6151 ...     {*assert
6152 ...         STR_IsDate( '2013.02.10' ) == true
6153 ...     *}
6154 ... 
6155 ...     {*assert
6156 ...         STR_IsDate( '2013.15.10' ) == false
6157 ...     *}
6158 ... 
6159 ...     {*assert
6160 ...         STR_IsDate( '2013.02.31' ) == true // even if date is wrong
6161 ...     *}
6162 ... 
6163 ...     {*assert
6164 ...         STR_IsDate( '2013.02.32' ) == false
6165 ...     *}
6166 ... 
6167 ...     *}}
6168 ...  */
6169 ... /* ========================================================================== */
6170 ... function STR_IsDate( $szDate )
6171 ... /*--------------------------*/
6172 ... {
6173 ...     return( preg_match( '%([0-5][0-9])[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])%',$szDate ) );
6174 ... }
6175 ... 
6176 ... /* ========================================================================== */
6177 ... /** {{*STR_SquareBracketsToAngleBrackets( $szText )=
6178 ... 
6179 ...     Turns square brackets to angle brackets
6180 ... 
6181 ...     {*params
6182 ...         $szText     (string)    Text to process
6183 ...     *}
6184 ... 
6185 ...     {*return
6186 ...         (string)    Square brackets turned to angle brackets
6187 ...     *}
6188 ... 
6189 ...     {*cdate 22/09/2013 *}
6190 ...     {*version 5.6.0000 *}
6191 ...     {*author  *}
6192 ...     {*mdate 14/09/2014 h1,h2,h3 support *}
6193 ... 
6194 ...     {*alias STR_FromSquareBracketsToAngleBrackets()
6195 ...     *}
6196 ... 
6197 ...     {*assert
6198 ...         STR_SquareBracketsToAngleBrackets( '[ol][li]...[/li][/ol]' ) === '<ol><li>...</li></ol>'
6199 ...     *}
6200 ... 
6201 ...     {*assert
6202 ...         STR_SquareBracketsToAngleBrackets( '[h1][/h1]' ) === '<h1></h1>'
6203 ...     *}
6204 ... 
6205 ...     {*assert
6206 ...         STR_SquareBracketsToAngleBrackets( '[h2][/h2]' ) === '<h2></h2>'
6207 ...     *}
6208 ... 
6209 ...     {*assert
6210 ...         STR_SquareBracketsToAngleBrackets( '[h3][/h3]' ) === '<h3></h3>'
6211 ...     *}
6212 ... 
6213 ...     {*seealso
6214 ...         STR_AngleBracketsToSquareBrackets()
6215 ...     *}
6216 ... 
6217 ...     *}}
6218 ...  */
6219 ... /* ========================================================================== */
6220 ... function STR_SquareBracketsToAngleBrackets( $szText )
6221 ... /*-------------------------------------------------*/
6222 ... {
6223 ...     return ( str_replace( array( '[br]'  ,'[hr]'  ,'[p]' ,'[/p]' ,'[b]'     ,'[/b]'     ,'[q]','[/q]','[i]' ,'[/i]' ,'<br>'  ,'[h1]','[/h1]','[h2]','[/h2]','[h3]','[/h3]','[ul]','[/ul]','[ol]','[/ol]','[li]','[/li]','[url]' ,'[/url]'  )   ,
6224 ...                           array( '<br />','<hr />','<p>' ,'</p>' ,'<strong>','</strong>','<q>','</q>','<em>','</em>','<br />','<h1>','</h1>','<h2>','</h2>','<h3>','</h3>','<ul>','</ul>','<ol>','</ol>','<li>','</li>','[http]','[/http]' )   ,
6225 ...                           $szText ) );
6226 ... }
6227 ... function STR_FromSquareBracketsToAngleBrackets( $szText )   { return ( STR_SquareBracketsToAngleBrackets( $szText ) ); }
6228 ... 
6229 ... 
6230 ... /* ========================================================================== */
6231 ... /** {{*STR_AngleBracketsToSquareBrackets( $szText )=
6232 ... 
6233 ...     Turns angle brackets to square brackets
6234 ... 
6235 ...     {*params
6236 ...         $szText     (string)    Text to process
6237 ...     *}
6238 ... 
6239 ...     {*return
6240 ...         (string)    Angle brackets turned to square brackets
6241 ...     *}
6242 ... 
6243 ...     {*cdate 22/09/2013 *}
6244 ...     {*version 5.6.0000 *}
6245 ...     {*author  *}
6246 ...     {*mdate 14/09/2014 h1,h2,h3 support *}
6247 ... 
6248 ...     {*alias
6249 ...         STR_FromAngleBracketsToSquareBrackets()
6250 ...     *}
6251 ... 
6252 ...     {*assert
6253 ...         STR_AngleBracketsToSquareBrackets( '<ol><li>...</li></ol>' ) === '[ol][li]...[/li][/ol]'
6254 ...     *}
6255 ... 
6256 ...     {*assert
6257 ...         STR_SquareBracketsToAngleBrackets( '<h1></h1>' ) === '[h1][/h1]'
6258 ...     *}
6259 ... 
6260 ...     {*assert
6261 ...         STR_SquareBracketsToAngleBrackets( '<h2></h2>' ) === '[h2][/h2]'
6262 ...     *}
6263 ... 
6264 ...     {*assert
6265 ...         STR_SquareBracketsToAngleBrackets( '<h3></h3>' ) === '[h3][/h1]'
6266 ...     *}
6267 ... 
6268 ...     {*seealso
6269 ...         STR_SquareBracketsToAngleBrackets()
6270 ...     *}
6271 ... 
6272 ...     *}}
6273 ...  */
6274 ... /* ========================================================================== */
6275 ... function STR_AngleBracketsToSquareBrackets( $szText )
6276 ... /*-------------------------------------------------*/
6277 ... {
6278 ...     return ( str_replace( array( '<br />','<hr />','<p>' ,'</p>', '<strong>','</strong>','<q>','</q>','<em>','</em>','<br />','<h1>','</h1>','<h2>','</h2>','<h3>','</h3>','<ul>','</ul>','<ol>','</ol>','<li>','</li>','[http]','[/http]' )   ,
6279 ...                           array( '[br]'  ,'[hr]'  ,'[p]' ,'[/p]', '[b]'     ,'[/b]'     ,'[q]','[/q]','[i]' ,'[/i]' ,'<br>'  ,'[h1]','[/h1]','[h2]','[/h2]','[h3]','[/h3]','[ul]','[/ul]','[ol]','[/ol]','[li]','[/li]','[url]' ,'[/url]'  )   ,
6280 ...                           $szText ) );
6281 ... }   /* End of STR_AngleBracketsToSquareBrackets() =========================== */
6282 ... function STR_FromAngleBracketsToSquareBrackets( $szText )   { return ( STR_AngleBracketsToSquareBrackets( $szText ) ); }
6283 ... 
6284 ... /* ========================================================================== */
6285 ... /** {{*STR_AngleBracketsToSquareBracketsEx( $szText )=
6286 ... 
6287 ...     Turns angle brackets to square brackets (extended version: transformation
6288 ...     done via regular expressions)
6289 ... 
6290 ...     {*params
6291 ...         $szText     (string)    Text to process
6292 ...     *}
6293 ... 
6294 ...     {*return
6295 ...         (string)    Angle brackets turned to square brackets
6296 ...     *}
6297 ... 
6298 ...     {*cdate 27/01/2015 *}
6299 ...     {*version 7.0.0001 *}
6300 ...     {*author  *}
6301 ... 
6302 ...     {*assert
6303 ...         STR_AngleBracketsToSquareBracketsEx( '<ol class="menu"><li class="first"><p class="warning" data-editable="true">Hello</p></li></ol>' ) === '[ol class="menu"][li class="first"][p class="warning" data-editable="true"]Hello[/p][/li][/ol]'
6304 ...     *}
6305 ... 
6306 ...     {*assert
6307 ...         STR_AngleBracketsToSquareBracketsEx( '<article class="pm"><?php include(file.txt); ?></article>' ) === '[article class="pm"][php include(file.txt); /php][/article]'
6308 ...     *}
6309 ... 
6310 ... 
6311 ...     {*seealso
6312 ...         STR_AngleBracketsToSquareBrackets()
6313 ...     *}
6314 ... 
6315 ...     *}}
6316 ...  */
6317 ... /* ========================================================================== */
6318 ... function STR_AngleBracketsToSquareBracketsEx( $szText )
6319 ... /*---------------------------------------------------*/
6320 ... {
6321 ...     $szText = preg_replace( array( '/<\?php(.*?)\?>/sim'                ,
6322 ...                                    '%<([A-Z][A-Z0-9]*)([^>]*)/>%sim' )  ,
6323 ...                             array( '[php$1/php]'                        ,
6324 ...                                    '[$1$2/]' ),$szText );
6325 ... 
6326 ...     while ( true )
6327 ...     {
6328 ...         $szNewText  = preg_replace( '%<([A-Z][A-Z0-9]*)([^>]*)>(.*?)</\1>%sim','[$1$2]$3[/$1]',$szText );
6329 ... 
6330 ...         //echo "STR_AngleBracketsToSquareBracketsEx(): ...",htmlentities( $szText ),"<br />\n";
6331 ... 
6332 ...         if ( $szText !== $szNewText )
6333 ...         {
6334 ...             //echo "<p>Should keep going</p>";
6335 ...             $szText = $szNewText;
6336 ...         }
6337 ...         else
6338 ...         {
6339 ...             //echo "<p>Can stop iterating</p>";
6340 ...             break;
6341 ...         }
6342 ...     }
6343 ... 
6344 ...     return ( $szText );
6345 ... }   /* End of STR_AngleBracketsToSquareBracketsEx() ========================= */
6346 ... 
6347 ... /* ========================================================================== */
6348 ... /** {{*STR_SquareBracketsToAngleBracketsEx( $szText )=
6349 ... 
6350 ...     Turns square brackets to angle brackets (extended version: transformation
6351 ...     done via regular expressions)
6352 ... 
6353 ...     {*params
6354 ...         $szText     (string)    Text to process
6355 ...     *}
6356 ... 
6357 ...     {*return
6358 ...         (string)    Square brackets turned to angle brackets
6359 ...     *}
6360 ... 
6361 ...     {*cdate 27/01/2015 *}
6362 ...     {*version 7.0.0001 *}
6363 ...     {*author  *}
6364 ... 
6365 ...     {*assert
6366 ...         STR_SquareBracketsToAngleBracketsEx( '[ol class="menu"][li class="first"][p class="warning" data-editable="true"]Hello[/p][/li][/ol]' ) === '<ol class="menu"><li class="first"><p class="warning" data-editable="true">Hello</p></li></ol>'
6367 ...     *}
6368 ... 
6369 ...     {*assert
6370 ...         STR_SquareBracketsToAngleBracketsEx( '[php include(myfile.txt); /php]' ) === '<?php include(myfile.txt); ?>'
6371 ...     *}
6372 ... 
6373 ...     {*assert
6374 ...         STR_SquareBracketsToAngleBracketsEx( "[php include(myfile.txt);\n /php]" ) === "<?php include(myfile.txt);\n ?>"
6375 ...     *}
6376 ... 
6377 ...     {*seealso
6378 ...         STR_SquareBracketsToAngleBrackets()
6379 ...     *}
6380 ... 
6381 ...     *}}
6382 ...  */
6383 ... /* ========================================================================== */
6384 ... function STR_SquareBracketsToAngleBracketsEx( $szText )
6385 ... /*---------------------------------------------------*/
6386 ... {
6387 ... 
6388 ...     $szText = preg_replace( array( '%\[php(.*?)/php\]%sim'                  ,
6389 ...                                    '%\[([A-Z][A-Z0-9]*)([^\]]*)/\]%sim' )   ,
6390 ...                             array( '<?php$1?>'                              ,
6391 ...                                     '<$1$2/>' ),$szText );
6392 ... 
6393 ...     while ( true )
6394 ...     {
6395 ...         $szNewText  = preg_replace( '%\[([A-Z][A-Z0-9]*)([^\]]*)\](.*?)\[/\1\]%sim','<$1$2>$3</$1>',$szText );
6396 ... 
6397 ...         if ( $szText !== $szNewText )
6398 ...         {
6399 ...             $szText = $szNewText;
6400 ...         }
6401 ...         else
6402 ...         {
6403 ...             break;
6404 ...         }
6405 ...     }
6406 ... 
6407 ...     return ( $szText );
6408 ... }   /* End of STR_SquareBracketsToAngleBracketsEx() ========================= */
6409 ... 

demoiselle: je passe par le cas par défaut

éventails: je passe par le cas par défaut

matières: je passe par le cas par défaut

noms: je passe par le cas par défaut

abstraits: je passe par le cas par défaut

objets: je passe par le cas par défaut

funérailles: je passe par le cas par défaut

montagnes: je passe par le cas par défaut

avons: je passe par le cas par défaut

enzymes: je passe par le cas par défaut

enverrons: je passe par le cas par défaut

envoyâmes: je passe par le cas par défaut

envoyâtes: je passe par le cas par défaut

enverras: je passe par le cas par défaut

envoyions: je passe par le cas par défaut

ions: je passe par le cas par défaut

avions: je passe par le cas par défaut

envoies: je passe par le cas par défaut

dix: je passe par le cas par défaut

Manifest Constants

LS_STRINGS_FUNCTIONS: Remember that THESE functions have been declared

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

Sources required

LSStrings.inc: String constants

LIB_parse.php: Parsing lib (NOT Vae Soli!)

LSUnitTesting.class.php: Vae Soli! Unit Testing

LSHtml.functions.php: HTML functions

UltraEdit Syntax files

  1. UltraEdit keywords of LSStrings.functions.php
  2. UltraEdit Syntax of LSStrings.functions.php

Function List (TOC)

  1. STR_a(): Transforms 'a' variations (uppercase and lowercase) into 'a' equivalent
  2. STR_a2(): Transforms 'a' entities (uppercase and lowercase) into 'a' equivalent
  3. STR_aBetween(): Returns an array of string matches that fall between two delineators
  4. STR_aClasses(): Extracts the start and stop position of the classes contained in a source code
  5. STR_AddCode(): Adds an ASCII code to each character of a string.
  6. STR_AddSlash(): Adds a slash to $szStr only if rightmost character of $szStr is not a slash ($szChar, defaulted to '/').
  7. STR_aeiouy(): Transforms 'a','e','i','o',u','y' entities and variations (uppercase and lowercase) into their respective equivalents
  8. STR_aLines(): Splits a string into lines
  9. STR_AllChars(): Returns all the characters found in a string in a sorted manner.
  10. STR_AngleBracketsToSquareBrackets(): Turns angle brackets to square brackets
  11. STR_AngleBracketsToSquareBracketsEx(): Turns angle brackets to square brackets (extended version: transformation done via regular expressions)
  12. STR_asc(): Returns the ASCII value of the $c character
  13. STR_Ascii(): Sums ASCII characters of string
  14. STR_Ascii2(): Sums ASCII characters of string (multiplied by position)
  15. STR_aUniqueWords(): Taxonomize a string
  16. STR_aWords(): Returns an array containing all the words found inside $szStr
  17. STR_Balance(): Returns the portion of string that balances $szStart with $szEnd
  18. STR_Between(): Returns the portion of a string that falls between two delineators, exclusive or inclusive of the delineators
  19. STR_Binary(): Returns a binary representation of $szStr (bit by bit)
  20. STR_Carve(): Cuts a string into an array of strings
  21. STR_Chop(): Chops a string and inserts $cChar one character on two
  22. STR_DetectLanguage(): Detects language of a text automatically
  23. STR_Dionly(): Keeps only the digits of a string
  24. STR_e(): Transforms 'e' variations (uppercase and lowercase) into 'e' equivalent No assertion found for STR_e() (0 - 0)
  25. STR_e2(): Transforms 'e' entities (uppercase and lowercase) into 'e' equivalent No assertion found for STR_e2() (0 - 0)
  26. STR_Eliminate(): Eliminates all characters of $szCharList from $szStr
  27. STR_Empty(): Determines whether a string is empty or not
  28. STR_EndsWith(): Determines if $szStr ends with $szEnd
  29. STR_GeneratePassword(): Generates a password at random
  30. STR_Gets(): Gets line from string up to next CR+LF, or CR or LF
  31. STR_Hexa(): Turns a string to an hexa equivalent
  32. STR_htos(): Opposite function to STR_hexa()
  33. STR_i(): Transforms 'i' variations (uppercase and lowercase) into 'i' equivalent No assertion found for STR_i() (0 - 0)
  34. STR_i2(): Transforms 'i' entities (uppercase and lowercase) into 'i' equivalent No assertion found for STR_i2() (0 - 0)
  35. STR_iInList(): Determines whether $szValue can be found in a list of possible values ($aList) (case insensitive)
  36. STR_InList(): Determines whether $szValue can be found in a list of possible values ($aList) (case sensitive)
  37. STR_iPos(): Finds the position of first occurrence of a string (case insensitive)
  38. STR_IsConsonant(): Determines whether the first character of $cChar is a consonant
  39. STR_IsDate(): Determines whether $szStr respects the pattern of a date (YYYY?MM?DD)
  40. STR_isdigit(): Determines if the first character of a string is a digit
  41. STR_IsVowel(): Determines whether the first character of $cChar is a vowel
  42. STR_iTran(): Transforms every occurrence of $szToReplace by $szReplacement in $szString (case insensitive)
  43. STR_Keep(): Keeps only the characters of $szStr which can be found in $szChars
  44. STR_Last(): Determines the $iLength last characters of $szStr
  45. STR_LastPos(): Finds the position of the last occurrence of a substring in a string
  46. STR_Left(): Returns the $iCount leftmost characters of $szStr
  47. STR_MatchingWords(): Return all words that are close to $szWord from a character perspective (not meaning). In general it contains a number of collisions that can be quickly disregarded based on their ranking. The function returns an XML string No assertion found for STR_MatchingWords() (0 - 0)
  48. STR_Minify(): Extracts the start and stop position of the classes contained in a source code
  49. STR_nl2br(): Inserts HTML line breaks before all newlines in a string
  50. STR_Null(): Returns a null (ALWAYS)
  51. STR_o(): Transforms 'o' variations (uppercase and lowercase) into 'o' equivalent No assertion found for STR_o() (0 - 0)
  52. STR_o2(): Transforms 'o' entities (uppercase and lowercase) into 'o' equivalent No assertion found for STR_o2() (0 - 0)
  53. STR_padl(): Left padding of a string
  54. STR_padr(): Right padding of a string
  55. STR_PasswordStrength(): Checks the strength of a password No assertion found for STR_PasswordStrength() (0 - 0)
  56. STR_Peek(): Returns the ASCII code of a given character in a string.
  57. STR_PluralToSingular(): Get the singular form of a word
  58. STR_Poke(): Poke a character at given position in a string.
  59. STR_Pos(): Finds the position of first occurrence of a string (case sensitive)
  60. STR_Random(): Generates string at random
  61. STR_Reduce(): Reduces consecutive occurrences of the same character to only 1 occurrence
  62. STR_Reduce2(): Reduces consecutive occurrences of the same character to only 1 occurrence
  63. STR_RemovePHPComments(): Remove PHP Comments from a string (which is supposed to be PHP Code)
  64. STR_RemoveStartingSlash(): Removes starting slash from $szStr only if leftmost character of $szStr is a slash ($szChar, defaulted to '/').
  65. STR_Replicate(): Replicates a string
  66. STR_Right(): Returns the $iCount rightmost characters of $szStr
  67. STR_shl(): Shifts-Left a string by a given number of bits ($nBits).
  68. STR_shr(): Shifts-Right a string by a given number of bits ($nBits).
  69. STR_SingularToPlural(): Get the plural form of a word
  70. STR_Soothe(): Soothes a string by inserting one character every character
  71. STR_Sort(): Sorts a string
  72. STR_SquareBracketsToAngleBrackets(): Turns square brackets to angle brackets
  73. STR_SquareBracketsToAngleBracketsEx(): Turns square brackets to angle brackets (extended version: transformation done via regular expressions)
  74. STR_StartsWith(): Determines if $szStr starts with $szStart
  75. STR_StraightenBadEncoding(): Corrects few instances of bad character encoding. No assertion found for STR_StraightenBadEncoding() (0 - 0)
  76. STR_Strin(): Returns $szStr amputated from the last character
  77. STR_stripAccents(): Removes all accents from a string (WordPress implementation)
  78. STR_StripPHPTags(): Strip PHP tags
  79. STR_StripTags(): Strip tags but potentially leave comments
  80. STR_SyntaxColoring(): Syntax coloring of a string
  81. STR_Tao(): Simply returns what was given as input
  82. STR_Tran(): Transforms every occurrence of $szToReplace by $szReplacement in $szString
  83. STR_u(): Transforms 'u' variations (uppercase and lowercase) into 'u' equivalent No assertion found for STR_u() (0 - 0)
  84. STR_u2(): Transforms 'u' entities (uppercase and lowercase) into 'u' equivalent No assertion found for STR_u2() (0 - 0)
  85. STR_UnEntities(): Transforms all HTML entities into their equivalent characters No assertion found for STR_UnEntities() (0 - 0)
  86. STR_Vowels(): Keeps only the vowels of $szStr
  87. STR_y(): Transforms 'y' variations (uppercase and lowercase) into 'y' equivalent No assertion found for STR_y() (0 - 0)
  88. STR_y2(): Transforms 'y' entities (uppercase and lowercase) into 'y' equivalent No assertion found for STR_y2() (0 - 0)
  89. STR_Yranib(): Reverse function of STR_Binary()

Functions of LSStrings.functions.php

STR_a(): Transforms 'a' variations (uppercase and lowercase) into 'a' equivalent

[ back to function list ]

Syntax

STR_a( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'a' variations (uppercase and lowercase) turned to 'a'

Assertions

STR_a( 'À demain' ) === 'a demain' failure

Unit Testing

1 assertions: 0 successful; 1 failed

See Also

STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_u(), STR_u2(), STR_y(), STR_y2()

STR_a2(): Transforms 'a' entities (uppercase and lowercase) into 'a' equivalent

[ back to function list ]

Syntax

STR_a2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'a' entities (uppercase and lowercase) turned to 'a'

Assertions

STR_a2( '&Agrave; demain' ) === 'a demain' // chr(65) + 'Agrave' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_a(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_u(), STR_u2(), STR_y(), STR_y2()

STR_aBetween(): Returns an array of string matches that fall between two delineators

[ back to function list ]

Syntax

STR_aBetween( $szStr,$szStart,$szStop )

Parameters
NameTypeDescription
$szStr string Input string to parse
$szStart string Defines the beginning of the sub string
$szStop string Defines the end of the sub string
Return

(array) Array of matches or null if not found

Example Executed
$szStr      = "MyFunction(BBB) is beautiful (even if it's not really mine)";
$aMatches   = STR_aBetween( $szStr,'(',')' );
var_dump( $aMatches );

echo LSUnitTesting::assert( count( $aMatches ) === 2                    ,
                            'ASSERTION SUCCESSFUL: correct extraction 1'  ,
                            'ASSERTION FAILURE: invalid extraction'     ,
                            'GuideAssert' );
$szStr      = "<html><body><p>This is what I want to extract</p></body></html>";
$aMatches   = STR_aBetween( $szStr,'<body>','</body>' );
var_dump( $aMatches );

echo LSUnitTesting::assert( count( $aMatches ) === 1 &&
                            preg_match( '/<body>(.*)<\/body>/si',$aMatches[0] ) ,
                            'ASSERTION SUCCESSFUL: correct extraction 2'          ,
                            'ASSERTION FAILURE: invalid extraction'             ,
                            'GuideAssert' );

$aMatches   = STR_aBetween( $szStr,'<html>','</p>' );
var_dump( $aMatches );

echo LSUnitTesting::assert( $aMatches[0] === "<html><body><p>This is what I want to extract</p>",
                            'ASSERTION SUCCESSFUL: correct extraction 3'                          ,
                            'ASSERTION FAILURE: invalid extraction'                             ,
                            'GuideAssert' );

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:3:
array (size=2)
  0 => string '(BBB)' (length=5)
  1 => string '(even if it's not really mine)' (length=30)

GuideAssert() ... ASSERTION SUCCESSFUL: correct extraction 1

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:11:
array (size=1)
  0 => string '<body><p>This is what I want to extract</p></body>' (length=50)

GuideAssert() ... ASSERTION SUCCESSFUL: correct extraction 2

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:20:
array (size=1)
  0 => string '<html><body><p>This is what I want to extract</p>' (length=49)

GuideAssert() ... ASSERTION SUCCESSFUL: correct extraction 3

Unit Testing

3 assertions: 3 successful; 0 failed

STR_aClasses(): Extracts the start and stop position of the classes contained in a source code

[ back to function list ]

Syntax

STR_aClasses( $szStr,$szKeyword )

Parameters
NameTypeDescription
$szStr string The source code string to process. Passed by reference but NOT touched.
$szKeyword string Keyword to look for. Optional. 'class' by default.
Return

(array) An array of start and stop position per class

Example Executed
echo "<p></p>The source code below is a fake and incorrect one!!!</p>";
$szSrcCode = <<< MSG
class MyClass
/*---------*/
{
    public class = 'Anything';    /* {*property class is something weird *} */

    public function Aclass()
    /*--------------------*/
    {
        echo __METHOD__;
    }
}

class MyOtherClass
/*--------------*/
{
    public class = 'Anything';    /* {*property class is something weird *} */

    public function Bclass()
    /*--------------------*/
    {
        echo __METHOD__;
    }
}

interface LSSentanaiInterface
/*=========================*/
{
    /* ====================================================================== */
    /** {{*PopulateFromXMLNode( oXPath,oNode )=

        Populates an object with values stored in the XML file (data storage).
        Current node is considered.

        {*params
            oXPath     (LSXPath)   The XPath object
            oNode      (DOMNode)   A DOMNode object that will be used to obtain
                                    the inner values
        *}

        {*return
            (bool)  [c]true[/c] if object successfully populated; [c]false[/c]
                    otherwise.
        *}

        *}}
     */
    /* ====================================================================== */
    public function PopulateFromXMLNode( oXPath,oNode );
    public function ThrowUp();
    public function __toString();
}   /* End of LSSentanaiInterface interface */

MSG;
echo $szSrcCode;

$aPositions = STR_aClasses( $szSrcCode );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 2  && 
                            ( $aPositions[0][0] === 0   && $aPositions[0][1] === 215 ) &&
                            ( $aPositions[1][0] === 220 && $aPositions[1][1] === 445 ),
                            'ASSERTION SUCCESSFUL: positions of classes correcty determined',
                            'ASSERTION FAILURE: incorrect detection of classes'              ,
                            'GuideAssert' );
$aPositions = STR_aClasses( $szSrcCode,'prelude' );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 0                                                  ,
                            'ASSERTION SUCCESSFUL: positions of prelude structures correcty determined' ,
                            'ASSERTION FAILURE: incorrect detection of preludes'                        ,
                            'GuideAssert' );
$aPositions = STR_aClasses( $szSrcCode,'interface' );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 1  &&
                            ( $aPositions[0][0] === 450 && $aPositions[0][1] === 1360 )                     ,
                            'ASSERTION SUCCESSFUL: positions of interface structures correcty determined'   ,
                            'ASSERTION FAILURE: incorrect detection of interfaces'                          ,
                            'GuideAssert' );


The source code below is a fake and incorrect one!!!

class MyClass /*---------*/ { public class = 'Anything'; /* {*property class is something weird *} */ public function Aclass() /*--------------------*/ { echo __METHOD__; } } class MyOtherClass /*--------------*/ { public class = 'Anything'; /* {*property class is something weird *} */ public function Bclass() /*--------------------*/ { echo __METHOD__; } } interface LSSentanaiInterface /*=========================*/ { /* ====================================================================== */ /** {{*PopulateFromXMLNode( oXPath,oNode )= Populates an object with values stored in the XML file (data storage). Current node is considered. {*params oXPath (LSXPath) The XPath object oNode (DOMNode) A DOMNode object that will be used to obtain the inner values *} {*return (bool) [c]true[/c] if object successfully populated; [c]false[/c] otherwise. *} *}} */ /* ====================================================================== */ public function PopulateFromXMLNode( oXPath,oNode ); public function ThrowUp(); public function __toString(); } /* End of LSSentanaiInterface interface */
D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:59:
array (size=2)
  0 => 
    array (size=2)
      0 => int 0
      1 => int 215
  1 => 
    array (size=2)
      0 => int 220
      1 => int 445

GuideAssert() ... ASSERTION SUCCESSFUL: positions of classes correcty determined

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:67:
array (size=0)
  empty

GuideAssert() ... ASSERTION SUCCESSFUL: positions of prelude structures correcty determined

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:73:
array (size=1)
  0 => 
    array (size=2)
      0 => int 450
      1 => int 1360

GuideAssert() ... ASSERTION SUCCESSFUL: positions of interface structures correcty determined

Unit Testing

3 assertions: 3 successful; 0 failed

STR_AddCode(): Adds an ASCII code to each character of a string.

[ back to function list ]

Syntax

STR_AddCode( $szStr,$iCode )

Parameters
NameTypeDescription
$szStr string String to process
$iCode int ASCII code to add to each character.
Return

(string) Resulting string

Example(s)
echo STR_AddCode( "12345678",1 );    Prints "23456789"
Assertions

STR_AddCode( "12345678",1 ) === "23456789" successful

STR_AddCode( "Hello World",255 ) === "Hello World" successful

STR_AddCode( "Hello World",256 ) === "Ifmmp!Xpsme" successful

STR_AddCode( " ",1 ) === "!!!" successful

Unit Testing

4 assertions: 4 successful; 0 failed

STR_AddSlash(): Adds a slash to $szStr only if rightmost character of $szStr is not a slash ($szChar, defaulted to '/').

[ back to function list ]

Warning

$szChar should be a single character for the function to work as expected and documented. Make sure you do not pass an empty string ($szStr )

Syntax

STR_AddSlash( $szStr,$szChar )

Parameters
NameTypeDescription
$szStr string Input string
$szChar char Slash character. Optional. '/' by default.
Return

(string) The resulting string

Example(s)
$szURL = 'http://www.latosensu.be/articles';
echo STR_AddSlash( $szURL ) . 'core/php/strings.php'; // Prints 'http://www.latosensu.be/articles/core/php/strings.php'
Assertions

STR_AddSlash( 'http://www.latosensu.be/' ) === 'http://www.latosensu.be/' successful

STR_AddSlash( 'http://www.latosensu.be' ) === 'http://www.latosensu.be/' successful

STR_AddSlash( 'http://www.latosensu.be','\\' ) === 'http://www.latosensu.be\\' successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_aeiouy(): Transforms 'a','e','i','o',u','y' entities and variations (uppercase and lowercase) into their respective equivalents

[ back to function list ]

Syntax

STR_aeiouy( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All variations (uppercase and lowercase) turned to their equivalents

Assertions

STR_aeiouy( 'À demain, ce sera un bel &eacute;t&eacute;' ) === 'a demain, ce sera un bel ete' failure

Unit Testing

1 assertions: 0 successful; 1 failed

STR_aLines(): Splits a string into lines

[ back to function list ]

Warning

Empty lines are disregarded

Syntax

STR_aLines( $szStr )

Parameters
NameTypeDescription
$szStr string String to slice in lines
Return

(array) Each cell of the array is a line. Empty lines are NOT taken into account (spaces are NOT considered as empty characters).

Example Executed
$szCode  = "\r\n";
$szCode .= "             \r\n";
$szCode .= '                    echo \'<p>\',$iDate1=SetExpiry( 2012,12,31,23,59,59 ),\'</p>\'; // 1972387238399' . "\r\n";
$szCode .= '        echo \'<p>\',$iDate2=SetExpiry( 2015,1,1 ),\'</p>\';            // 1975295980800' . "\r\n";
$szCode .= '        if ( $iDate2 > $iDate1 )' . "\r\n";
$szCode .= '        {' . "\r\n";
$szCode .= '            echo \'<p>$iDate2 &gt; $iDate1</p>\';' . "\r\n";
$szCode .= '        }';

$aLines  = STR_aLines( $szCode );
// 'There are 7 lines of code' ... because the 1st one is empty
echo "<p>There are " . ( $iCount = count( $aLines ) ) .
         " lines of code</p>\n";
var_dump( $aLines );
echo LSUnitTesting::assert( $iCount === 7,
                            'ASSERTION SUCCESSFUL: lines correctly counted',
                            'ASSERTION FAILURE: lines incorrectly counted',
                            'GuideAssert' );

There are 7 lines of code

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:14:
array (size=7)
  0 => string '
             ' (length=14)
  1 => string '
                    echo '<p>',$iDate1=SetExpiry( 2012,12,31,23,59,59 ),'</p>'; // 1972387238399' (length=97)
  2 => string '
        echo '<p>',$iDate2=SetExpiry( 2015,1,1 ),'</p>';            // 1975295980800' (length=85)
  3 => string '
        if ( $iDate2 > $iDate1 )' (length=33)
  4 => string '
        {' (length=10)
  5 => string '
            echo '<p>$iDate2 &gt; $iDate1</p>';' (length=48)
  6 => string '
        }' (length=10)

GuideAssert() ... ASSERTION SUCCESSFUL: lines correctly counted

Unit Testing

1 assertions: 1 successful; 0 failed

STR_AllChars(): Returns all the characters found in a string in a sorted manner.

[ back to function list ]

Remark

This algorithm is used in SCRABBLE for example ... to locate ANY word that contains all letters, or 7 letters, or 6 letters, etc. Each character of the original string will be reported only once in the resulting string.

Syntax

STR_AllChars( $szStr,$iType )

Parameters
NameTypeDescription
$szStr string String to process
$iType int Optional. Type of treatment:
0 ... case-sensitive (default)
1 ... uses uppercase algorithm
2 ... uses lowercase algorithm.
Return

(string) Resulting string. If $iType == 1, the returned string is in uppercase; if $iType == 2, the returned string is in lowercase.

Example(s)
$szString = "Hello World"

echo STR_AllChars( $szString   ) // " HWdelor"
echo STR_AllChars( $szString,0 ) // " HWdelor"
echo STR_AllChars( $szString,1 ) // " DEHLORW"
echo STR_AllChars( $szString,2 ) // " dehlorw"
Assertions

STR_AllChars( "Hello World" ) === " HWdelor" successful

STR_AllChars( "Hello World",0 ) === " HWdelor" successful

STR_AllChars( "Hello World",1 ) === " DEHLORW" successful

STR_AllChars( "Hello World",2 ) === " dehlorw" successful

STR_AllChars( "Hello World",5 ) === " HWdelor" successful

Unit Testing

5 assertions: 5 successful; 0 failed

STR_AngleBracketsToSquareBrackets(): Turns angle brackets to square brackets

[ back to function list ]

Created: 22/09/2013

Since version 5.6.0000

Modified: 14/09/2014 h1,h2,h3 support

Author

Syntax

STR_AngleBracketsToSquareBrackets( $szText )

Alias

STR_FromAngleBracketsToSquareBrackets()

Parameters
NameTypeDescription
$szText string Text to process
Return

(string) Angle brackets turned to square brackets

Assertions

STR_AngleBracketsToSquareBrackets( '<ol><li>...</li></ol>' ) === '[ol][li]...[/li][/ol]' successful

STR_SquareBracketsToAngleBrackets( '<h1></h1>' ) === '[h1][/h1]' failure

STR_SquareBracketsToAngleBrackets( '<h2></h2>' ) === '[h2][/h2]' failure

STR_SquareBracketsToAngleBrackets( '<h3></h3>' ) === '[h3][/h1]' failure

Unit Testing

4 assertions: 1 successful; 3 failed

See Also

STR_SquareBracketsToAngleBrackets()

STR_AngleBracketsToSquareBracketsEx(): Turns angle brackets to square brackets (extended version: transformation done via regular expressions)

[ back to function list ]

Created: 27/01/2015

Since version 7.0.0001

Author

Syntax

STR_AngleBracketsToSquareBracketsEx( $szText )

Parameters
NameTypeDescription
$szText string Text to process
Return

(string) Angle brackets turned to square brackets

Assertions

STR_AngleBracketsToSquareBracketsEx( '<ol class="menu"><li class="first"><p class="warning" data-editable="true">Hello</p></li></ol>' ) === '[ol class="menu"][li class="first"][p class="warning" data-editable="true"]Hello[/p][/li][/ol]' successful

STR_AngleBracketsToSquareBracketsEx( '<article class="pm"><?php include(file.txt); ?></article>' ) === '[article class="pm"][php include(file.txt); /php][/article]' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_AngleBracketsToSquareBrackets()

STR_asc(): Returns the ASCII value of the $c character

[ back to function list ]

Remark

This function is more to be used under its alias form: asc(). It uses the ord() PHP built-in function

Syntax

STR_asc( $c )

Alias

asc()

Parameters
NameTypeDescription
$c char The character whose ASCII value must be returned
Return

(int) Returns the ASCII value of $c as an integer

Assertions

STR_Asc( 'A' ) === 65 successful

STR_Asc( 'AB' ) === 65 successful

STR_Asc( 'B' ) === 66 successful

STR_Asc( ' ' ) === 32 successful

Unit Testing

4 assertions: 4 successful; 0 failed

STR_Ascii(): Sums ASCII characters of string

[ back to function list ]

Syntax

STR_Ascii( $szStr )

Parameters
NameTypeDescription
$szStr string The string that must be treated
Return

(int) Sum of all ASCII chars; 0 if 0 length string

Example Executed
echo $iSum = STR_Ascii( 'Hello World' );
echo LSUnitTesting::assert( $iSum === 1052                              ,
                            'ASSERTION SUCCESSFUL: correct ASCII value' ,
                            'ASSERTION FAILURE: incorrect ASCII value'  ,
                            'GuideAssert' );

1052

GuideAssert() ... ASSERTION SUCCESSFUL: correct ASCII value

Assertions

STR_Ascii( 'A' ) === 65 successful

STR_Ascii( STR_Replicate( 'A',4 ) ) === ( 4 * STR_Ascii( 'A' ) ) successful

STR_Ascii( 'AA' ) === 130 successful

STR_Ascii( 'Ab' ) === STR_Ascii( 'bA' ) successful

Unit Testing

5 assertions: 5 successful; 0 failed

See Also

STR_Ascii2()

STR_Ascii2(): Sums ASCII characters of string (multiplied by position)

[ back to function list ]

Syntax

STR_Ascii2( $szStr )

Parameters
NameTypeDescription
$szStr string The string that must be treated
Return

(int) Sum of all ASCII chars (each char is multiplied by its position); 0 if 0 length string

Example Executed
echo $iSum = STR_Ascii2( 'Hello World' );
echo LSUnitTesting::assert( $iSum === 5428                                  ,
                            'ASSERTION SUCCESSFUL: correct ASCII 2 value'   ,
                            'ASSERTION FAILURE: incorrect ASCII 2 value'    ,
                            'GuideAssert' );

5428

GuideAssert() ... ASSERTION SUCCESSFUL: correct ASCII 2 value

Assertions

STR_Ascii2( 'Ab' ) !== STR_Ascii2( 'bA' ) successful

STR_Ascii( 'Ab' ) !== STR_Ascii2( 'Ab' ) successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_Ascii()

STR_aUniqueWords(): Taxonomize a string

[ back to function list ]

Since version 6.0.0001

Author

Warning

Experimental function. Do not use in a production environment yet (22-04-14 15:24:22)

Syntax

STR_aUniqueWords( $szStr )

Parameters
NameTypeDescription
$szStr string The text whose words must be extracted
Return

(array) An array of words found in $szStr. The words are sorted in such a way that the most frequent words appear first.

Example Executed
$szStr = 'Project prioritization ... Agility: the power of moving '             .
         'quickly and easily. Ability to think and draw conclusions '           .
         'quickly; intellectual acuity", this is what we need to bear in '      .
         'mind when we speak about "Agile Methods"! Now think about the '       .
         'way estimates are requested, think about the way people make '        .
         'them, think about the way it is required to refine them in '          .
         'multiple rounds, think about the way they serve '                     .
         '"negotiations/bargains", think of how the value of a project is '     .
         'calculated, evaluated or forged, think ... Are we really agile in '   .
         'these matters? No, we\'re not! We\'ve outgrown all that now and '     .
         'it\'s to us to update the unwritten rules of Project Portfolio '      .
         'Management, of Project Management and of Product Development. '       .
         'It\'s up to us to change the rules of how agility should be '         .
         'embraced when dealing with all the processes we must follow. '        .
         'With this post we shall introduce a surprising way to weight '        .
         'projects and how to prioritize them in minutes instead of hours '     .
         'or even days or weeks! That\'s a way to become agile in that '        .
         'matter. <strong>It\'s LEAN!</strong>';
$aWords = STR_aUniqueWords( $szStr );
var_dump( $aWords );

echo LSUnitTesting::assert( count( $aWords ) === 84                         ,
                            'ASSERTION SUCCESSFUL: correct number of words' ,
                            'ASSERTION FAILURE: incorrect number of words'  ,
                            'GuideAssert' );

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:20:
array (size=84)
  'the' => int 9
  'think' => int 7
  'way' => int 6
  'and' => int 5
  'about' => int 5
  'project' => int 4
  'that' => int 3
  'how' => int 3
  'them' => int 3
  'agile' => int 3
  'when' => int 2
  'rules' => int 2
  'management' => int 2
  'with' => int 2
  'are' => int 2
  'now' => int 2
  'all' => int 2
  'agility' => int 2
  'this' => int 2
  'quickly' => int 2
  'projects' => int 1
  'dealing' => int 1
  'update' => int 1
  'unwritten' => int 1
  'matter' => int 1
  'portfolio' => int 1
  'become' => int 1
  'product' => int 1
  'development' => int 1
  'change' => int 1
  'should' => int 1
  'embraced' => int 1
  'days' => int 1
  'weeks' => int 1
  'weight' => int 1
  'processes' => int 1
  'must' => int 1
  'follow' => int 1
  'even' => int 1
  'post' => int 1
  'hours' => int 1
  'instead' => int 1
  'outgrown' => int 1
  'minutes' => int 1
  'introduce' => int 1
  'prioritize' => int 1
  'surprising' => int 1
  'shall' => int 1
  'value' => int 1
  'not' => int 1
  'acuity' => int 1
  'methods' => int 1
  'speak' => int 1
  'mind' => int 1
  'bear' => int 1
  'need' => int 1
  'what' => int 1
  'intellectual' => int 1
  'requested' => int 1
  'conclusions' => int 1
  'draw' => int 1
  'ability' => int 1
  'easily' => int 1
  'moving' => int 1
  'power' => int 1
  'estimates' => int 1
  'people' => int 1
  'matters' => int 1
  'bargains' => int 1
  'these' => int 1
  'really' => int 1
  'forged' => int 1
  'evaluated' => int 1
  'calculated' => int 1
  'prioritization' => int 1
  'negotiations' => int 1
  'make' => int 1
  'serve' => int 1
  'they' => int 1
  'rounds' => int 1
  'multiple' => int 1
  'refine' => int 1
  'required' => int 1
  'lean' => int 1

GuideAssert() ... ASSERTION SUCCESSFUL: correct number of words

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Words()

STR_aWords(): Returns an array containing all the words found inside $szStr

[ back to function list ]

Syntax

STR_aWords( $szStr,$iType,$szList )

Alias

STR_Words()

Parameters
NameTypeDescription
$szStr string String to treat
$iType int Type of return. Optional. 0 = number of words
1 = array of words (default behavior);
$szList string Additional characters which will be considered as natural part of a 'word'. Optional.
Return

(array) An array with all words found in $szStr

Example Executed
var_dump( STR_aWords( 'Hello World' ) );
echo STR_aWords( 'Hello World',0 );

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:1:
array (size=2)
  0 => string 'Hello' (length=5)
  1 => string 'World' (length=5)
2
Assertions

count( STR_aWords( 'Hello World' ) ) === 2 successful

count( STR_aWords( 'Hello World',1 ) ) === 2 successful

count( STR_aWords( 'Hello World',2 ) ) === 2 successful

STR_aWords( 'Hello World',0 ) === 2 successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

STR_aUniqueWords()

STR_Balance(): Returns the portion of string that balances $szStart with $szEnd

[ back to function list ]

Syntax

STR_Balance( $szStr,$szStart,$szEnd )

Parameters
NameTypeDescription
$szStr string Input string
$szStart string Start of string pattern
$szEnd string End of string pattern
Return

(string) The string portion including $szStart and comprising $szEnd; null if no match found.

Example Executed
$szStr = '<div id="footer">' .
             '<address>Rue Bois des Mazuis, 47 - 5070 - Vitrival' .
                 '<div class="org">Lato Sensu Management</div>' .
             '</address>' .
         '</div><div><ol><li>Option 1</li><li>Option 2</li></ol></div>';

echo '<p style="border-bottom:1px solid #000;">Original string</p>';
echo $szStr;

echo '<p style="border-bottom:1px solid #000;">Footer div (balanced)</p>';
echo STR_Balance( $szStr,'<div','</div>' );

Original string

  1. Option 1
  2. Option 2

Footer div (balanced)

Assertions

STR_Balance( '<div id="myDiv"><h2>My title</h2><p>Hello</p></div>','<p>','</p>' ) === '<p>Hello</p>' successful

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Between(): Returns the portion of a string that falls between two delineators, exclusive or inclusive of the delineators

[ back to function list ]

Syntax

STR_Between( $szStr,$szStart,$szStop,$bType )

Parameters
NameTypeDescription
$szStr string Input string to parse
$szStart string Defines the beginning of the sub string
$szStop string Defines the end of the sub string
$bType bool INCL: include delineators in parsed string
EXCL: exclude delineators in parsed string
Parameters Warning

STR_Between() uses 4 parameters whereas the suggested limit is 3.

Return

(string) What is between $szStart and $szStop or null if not found

Assertions

STR_Between( 'The big house is blue','big','is',EXCL ) === ' house ' successful

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Binary(): Returns a binary representation of $szStr (bit by bit)

[ back to function list ]

Syntax

STR_Binary( $szStr )

Parameters
NameTypeDescription
$szStr string The string that must be turned to a binary representation. A single letter is represented by a string of 8 chars (A is for example turned to its binary representation as '01000001').
Return

(string) Binary representation of $szStr

Example Executed
$szBits = STR_Binary( 'A' );
echo '<p>',$szBits,'</p>';

$szBits = STR_Binary( 'B' );
echo '<p>',$szBits,'</p>';

$szBits = STR_Binary( 'Hello World' );
echo '<p>',$szBits,'</p>';

01000001

01000010

0100100001100101011011000110110001101111001000000101011101101111011100100110110001100100

Assertions

STR_Binary( 'A' ) === '01000001' successful

STR_Binary( 'B' ) === '01000010' successful

STR_Binary( 'AB' ) === '0100000101000010' successful

count( STR_Carve( STR_Binary( $szStr = 'Hello World' ),8 ) ) === strlen( $szStr ) successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

STR_Yranib()

STR_Carve(): Cuts a string into an array of strings

[ back to function list ]

Created: 22/04/2014 19:09

Since version 6.0.0006

Author

Syntax

STR_Carve( $szStr,$iLength )

Parameters
NameTypeDescription
$szStr string The string to process
$iLength int Maximum length of string chunk.
Return

(array) Array of strings

Example Executed
$szBin  = STR_Binary( "Hello World" );
$aChars = STR_Carve( $szBin,8 );

echo LSUnitTesting::assert( count( $aChars ) === 11                 ,
                            'ASSERTION SUCCESSFUL: string cut valid',
                            'ASSERTION FAILURE: invalid string cut' ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: string cut valid

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Chop(): Chops a string and inserts $cChar one character on two

[ back to function list ]

Created: 12/09/2013 13:12

Since version 5.5.0000

Author

Remark

trim() the string after STR_Chop() is you need the last default blank be removed

Syntax

STR_Chop( $szStr,$cChar )

Parameters
NameTypeDescription
$szStr string The string to process
$cChar char The character to insert Optional. ' ' (blank) by default
Return

(string) $szStr chopped with $cChar

Example Executed
echo '<p>',STR_Chop( 'Hello World' ),'</p>';

H e l l o W o r l d

Assertions

STR_Chop( 'Hello World' ) === 'H e l l o W o r l d ' successful

STR_Chop( 'Hello World','·' ) === 'H·e·l·l·o· ·W·o·r·l·d·' successful

STR_Chop( 'Hello World','|' ) === 'H|e|l|l|o| |W|o|r|l|d|' successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_DetectLanguage(): Detects language of a text automatically

[ back to function list ]

Warning

This function is experimental and works only for the following languages: catalan, czech, german, english, spanish, french, italian, dutch, portuguese

Syntax

STR_DetectLanguage( $szText,$szDefault,$iCount )

Parameters
NameTypeDescription
$szText string The text to process. By reference. Identical upon exit
$szDefault string Default language
$iCount int Number of words to use to detect the language. Optional : 50 by default;
Return

(string) $szStr amputated from all chars found in $szCharList

Example Executed
$szStr = "Ce texte est un texte écrit en français durant l'été";
echo LSUnitTesting::assert( STR_DetectLanguage( $szStr,'fr' ) == 'fr'       ,
                            'ASSERTION SUCCESSFUL: Language detection OK'   ,
                            'ASSERTION FAILURE: Language detection failed'  ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION FAILURE: Language detection failed

Unit Testing

1 assertions: 0 successful; 1 failed

STR_Dionly(): Keeps only the digits of a string

[ back to function list ]

Syntax

STR_Dionly( $szStr )

Alias

dionly(), STR_DigitsOnly()

Parameters
NameTypeDescription
$szStr string String to process
Return

(string) $szStr from which we kept the digits only

Example(s)
echo STR_Dionly( "I love these 101 dogs" );     // "101"
Assertions

STR_Dionly( 'This 1000 stars sky is less beautiful than your 2 eyes' ) === '10002' successful

STR_Dionly( " I love these 101 dogs " ) === "101" successful

Unit Testing

2 assertions: 2 successful; 0 failed

STR_e(): Transforms 'e' variations (uppercase and lowercase) into 'e' equivalent

[ back to function list ]

Syntax

STR_e( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'e' variations (uppercase and lowercase) turned to 'e'

Example(s)
echo STR_e( "C'est l'été. T'es prêt ?" );    // Prints "C'est l'ete. T'es pret ?"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_e2(): Transforms 'e' entities (uppercase and lowercase) into 'e' equivalent

[ back to function list ]

Syntax

STR_e2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'e' entities (uppercase and lowercase) turned to 'e'

Example(s)
echo STR_e2( "C'est l'&eacute;t&eacute;" );    // Prints "C'est l'ete"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_Eliminate(): Eliminates all characters of $szCharList from $szStr

[ back to function list ]

Syntax

STR_Eliminate( $szStr,$szCharList )

Alias

STR_Avoid()

Parameters
NameTypeDescription
$szStr string The string to process
$szCharList string The list of characters to get rid of
Return

(string) $szStr amputated from all chars found in $szCharList

Example Executed
$szStr   = "Hello World\nIs All OK?\r\nHave you seen Henry?";
$iLength = strlen( $szStr);
echo '<p>Length was: '                          ,
         $iLength                               ,
         '<br />'                               ,
         $szStr = STR_Eliminate( $szStr,"\r\n" ),
         '<br />New length is: '                ,
         $iLength = strlen( $szStr )            ,
         "</p>\n";
echo LSUnitTesting::assert( $iLength === 41                                     ,
                            'ASSERTION SUCCESSFUL: correct length for $szStr'   ,
                            'ASSERTION FAILURE: incorrect length for $szStr'    ,
                            'GuideAssert' );

Length was: 44
Hello WorldIs All OK?Have you seen Henry?
New length is: 41

GuideAssert() ... ASSERTION SUCCESSFUL: correct length for $szStr

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Keep()

STR_Empty(): Determines whether a string is empty or not

[ back to function list ]

Syntax

STR_Empty( $szStr )

Parameters
NameTypeDescription
$szStr string String to test
Return

(bool) true if $szStr is null or ''; false otherwise

Example Executed
echo '<p>',MISC_CastString( STR_Empty( ''       ) ),'</p>';
echo '<p>',MISC_CastString( STR_Empty( null     ) ),'</p>';
echo '<p>',MISC_CastString( STR_Empty( 'Hello'  ) ),'</p>';
echo '<p>',MISC_CastString( STR_Empty( '     '  ) ),'</p>';

true

true

false

false

Assertions

MISC_CastString( STR_Empty( '' ) ) === 'true' successful

MISC_CastString( STR_Empty( null ) ) === 'true' successful

MISC_CastString( STR_Empty( 'Hello' ) ) === 'false' successful

MISC_CastString( STR_Empty( ' ' ) ) === 'false' successful

Unit Testing

4 assertions: 4 successful; 0 failed

STR_EndsWith(): Determines if $szStr ends with $szEnd

[ back to function list ]

Syntax

STR_EndsWith( $szStr,$szEnd )

Alias

STR_EndWith()

Parameters
NameTypeDescription
$szStr string the string to examine
$szEnd string the string to look for
Return

(boolean) true if $szStr ends with $szEnd

Example(s)
if ( ! STR_EndsWith( $szFile,'/' ) )
{
    $szFile .= '/';
}
Assertions

STR_EndsWith( '.php=return (int) date( "d" );',';' ) === true successful

STR_EndsWith( 'Bonjour','jour' ) === true successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_Right(), STR_StartsWith()

STR_GeneratePassword(): Generates a password at random

[ back to function list ]

Modified: 14/10/2013 06:35

Author

Warning

Use this function with caution as it consumes some resources before it returns: the password is chosen amongst more than 3000 possible combinations.

Syntax

STR_GeneratePassword( $iLength )

Parameters
NameTypeDescription
$iLength int Minimum length of the password to be generated. Optional. -1 by default, which means NO minimal length.
Return

(string) Password at random

Example Executed
echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
                              STR_Pos( $szWord,"\r" ) === -1    &&
                              STR_Pos( $szWord, "\n" ) === -1               ,
                            'ASSERTION SUCCESSFUL: password seems to be OK' ,
                            'ASSERTION FAILURE: invalid password'           ,
                            'GuideAssert' );
echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
                              STR_Pos( $szWord,"\r" ) === -1    &&
                              STR_Pos( $szWord,"\n" )                       ,
                            'ASSERTION SUCCESSFUL: password seems to be OK' ,
                            'ASSERTION FAILURE: invalid password'           ,
                            'GuideAssert' );
echo '<p>',$szWord = STR_GeneratePassword(),'</p>';
echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
                              STR_Pos( $szWord,"\r" ) === -1    &&
                              STR_Pos( $szWord,"\n" )                       ,
                            'ASSERTION SUCCESSFUL: password seems to be OK' ,
                            'ASSERTION FAILURE: invalid password'           ,
                            'GuideAssert' );
echo '<p>',$szWord = STR_GeneratePassword(8),'</p>';
echo LSUnitTesting::assert( ! STR_Empty( $szWord )              &&
                              STR_Pos( $szWord,"\r" ) === -1    &&
                              STR_Pos( $szWord,"\n" ) === -1    &&
                              strlen( $szWord ) === 8                       ,
                            'ASSERTION SUCCESSFUL: password seems to be OK' ,
                            'ASSERTION FAILURE: invalid password'           ,
                            'GuideAssert' );

ut2rerumcaelestium

GuideAssert() ... ASSERTION SUCCESSFUL: password seems to be OK

teneritas

GuideAssert() ... ASSERTION SUCCESSFUL: password seems to be OK

quaedam2nunc

GuideAssert() ... ASSERTION SUCCESSFUL: password seems to be OK

qualia2m

GuideAssert() ... ASSERTION SUCCESSFUL: password seems to be OK

Assertions

STR_GeneratePassword() != STR_GeneratePassword() successful

! STR_Empty( STR_GeneratePassword() ) successful

Unit Testing

6 assertions: 6 successful; 0 failed

See Also

STR_Random()

STR_Gets(): Gets line from string up to next CR+LF, or CR or LF

[ back to function list ]

Warning

This function has not passed the approval process yet. Do not use in a production environment.

Syntax

STR_Gets( $szStr,$iPos )

Parameters
NameTypeDescription
$szStr string The source code to extract the next line from
$iPos int Starting position. Extraction starts at beginning of $szStr (0). Parameter passed by reference: updated upon return
Return

(string) Next line of text or null if problem

Example Executed
$szStr  = "Hello World\nIs All OK?\r\nHave you seen Henry?\n";
$aLines = array();
$i      = 1;

echo "\n";

while ( ! is_null( $szLine = STR_Gets( $szStr ) ) )
{
    if ( ! is_null( $szLine = "Line  " . $i++ . ": {$szLine}\n" ) );
    {
        $aLines[] = $szLine;
        echo "<p>",$szLine,"<p>";
    }
}

echo "<p>",STR_binary( $aLines[3] ),"<p>";

echo LSUnitTesting::assert( count( $aLines ) === 3                      ,
                            'ASSERTION SUCCESSFUL: correct line count'  ,
                            'ASSERTION FAILURE: incorrect line count'   ,
                            'GuideAssert' );


Line 1: Hello World

Line 2: Is All OK?

Line 3: Have you seen Henry?

Line 4:

01001100011010010110111001100101001000000010000000110100001110100010000000001010

GuideAssert() ... ASSERTION FAILURE: incorrect line count

Unit Testing

1 assertions: 0 successful; 1 failed

STR_Hexa(): Turns a string to an hexa equivalent

[ back to function list ]

Syntax

STR_Hexa( $szStr )

Alias

STR_stoh()

Parameters
NameTypeDescription
$szStr string String to transform into a suite of hex values
Return

(string) $szStr is transformed into hex equivalents

Example Executed
echo STR_Hexa( "Hello World" );

48656c6c6f20576f726c64
Assertions

STR_htos( STR_Hexa( $szStr = "Hello World" ) ) === $szStr successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_htos()

STR_htos(): Opposite function to STR_hexa()

[ back to function list ]

Modified: 22-04-14 19:55:11

Syntax

STR_htos( $szStr )

Parameters
NameTypeDescription
$szStr string Hex values turned to a string equivalent
Return

(string) $szStr is transformed into a string equivalent

Example Executed
echo $szStr = STR_htos( STR_hexa( "Hello World" ) );

Hello World
Assertions

STR_htos( STR_Hexa( $szStr = "Hello World" ) ) === $szStr successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_hexa()

STR_i(): Transforms 'i' variations (uppercase and lowercase) into 'i' equivalent

[ back to function list ]

Syntax

STR_i( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'i' variations (ìíîï) (uppercase and lowercase) turned to 'i'

Example(s)
echo STR_i( "C'est une belle île" );    // Prints "C'est une belle ile"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_i2(): Transforms 'i' entities (uppercase and lowercase) into 'i' equivalent

[ back to function list ]

Syntax

STR_i2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'i' entities (uppercase and lowercase) turned to 'i'

Example(s)
echo STR_i2( "C'est une belle &icirc;le" );    // Prints "C'est une belle ile"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_iInList(): Determines whether $szValue can be found in a list of possible values ($aList) (case insensitive)

[ back to function list ]

Remark

Case insensitive search

Syntax

STR_iInList( $aList,$szValue,$bPartOf )

Parameters
NameTypeDescription
$aList array Array of values
$szValue string The value to look for in $aList
$bPartOf boolean Optional. false by default. If true a partial match is accepted.
Return

(bool) true if $szValue found in $aList; false otherwise

Example(s)
if ( STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),$szPage ) )
{
    echo "<p>{$szPage} found in list!</p>\n";
}
Assertions

STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'/sitemap.php' ) === true successful

STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'/SITEMAP.PHP' ) === true successful

STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'map.php' ) === false successful

STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'MAP.PHP' ) === false successful

STR_iInList( array( '/sitemap.php','/help.php','/legal.php' ),'.php',true ) === true successful

Unit Testing

5 assertions: 5 successful; 0 failed

See Also

STR_InList()

STR_InList(): Determines whether $szValue can be found in a list of possible values ($aList) (case sensitive)

[ back to function list ]

Remark

Case sensitive search

Syntax

STR_InList( $aList,$szValue,$bPartOf )

Parameters
NameTypeDescription
$aList array Array of values
$szValue string The value to look for in $aList
$bPartOf boolean Optional. false by default. If true a partial match is accepted.
Return

(bool) true if $szValue found in $aList; false otherwise

Example(s)
if ( STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),$szPage ) )
{
    echo "<p>{$szPage} found in list!</p>\n";
}
Assertions

STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'/sitemap.php' ) === true successful

STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'/SITEMAP.PHP' ) === false successful

STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'map.php' ) === false successful

STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'MAP.PHP' ) === false successful

STR_InList( array( '/sitemap.php','/help.php','/legal.php' ),'legal',true ) === true successful

Unit Testing

5 assertions: 5 successful; 0 failed

See Also

STR_iInList()

STR_iPos(): Finds the position of first occurrence of a string (case insensitive)

[ back to function list ]

Syntax

STR_iPos( $szStr,$szSubStr,$iStart )

Parameters
NameTypeDescription
$szStr string String to be searched
$szSubStr string Substring to look for
$iStart int Optional offset parameter to specify where searching must start. 0 by default.
Return

(int) -1 if $szSubStr not found in $szStr; otherwise it indicates the 1st position where $szSubStr is found in $szStr

Example(s)
echo STR_iPos( '/index.php;/Index.php','/' ); // Prints 0
Assertions

STR_iPos( 'Hello','l' ) === 2 successful

STR_iPos( 'HeLlo','l' ) === 2 successful

STR_iPos( 'HeLlo','l',3 ) === 3 successful

STR_iPos( 'HeLlo','pa' ) === -1 successful

STR_iPos( 'C:/websites/latosensu.be/www/httpdocs/georama','C:/websites/latosensu.be/www/httpdocs' ) !== -1 successful

Unit Testing

5 assertions: 5 successful; 0 failed

See Also

STR_Pos()

STR_IsConsonant(): Determines whether the first character of $cChar is a consonant

[ back to function list ]

Syntax

STR_IsConsonant( $cChar )

Parameters
NameTypeDescription
$cChar string The string whose 1st character is to be checked
Return

(bool) true if $cChar[0] is a consonant; false otherwise

Assertions

STR_IsConsonant( 'Hello' ) === true successful

STR_IsConsonant( 'admittance' ) === false successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_IsVowel()

STR_IsDate(): Determines whether $szStr respects the pattern of a date (YYYY?MM?DD)

[ back to function list ]

Remark

Dates are checked against a YYYY MM DD pattern (year between 0000 and 5999)

Syntax

STR_IsDate( $szStr )

Parameters
NameTypeDescription
$szStr string The string to check for a date
Return

(bool) true if $szStr seems to be a date

Assertions

STR_IsDate( '1015.06.03' ) == true successful

STR_IsDate( '2015.06 03' ) == true successful

STR_IsDate( '5015 06 03' ) == true successful

STR_IsDate( '6015 06 03' ) == false successful

STR_IsDate( '2013/02/10' ) == true successful

STR_IsDate( '2013-02-10' ) == true successful

STR_IsDate( '2013.02.10' ) == true successful

STR_IsDate( '2013.15.10' ) == false successful

STR_IsDate( '2013.02.31' ) == true // even if date is wrong successful

STR_IsDate( '2013.02.32' ) == false successful

Unit Testing

10 assertions: 10 successful; 0 failed

STR_isdigit(): Determines if the first character of a string is a digit

[ back to function list ]

Syntax

STR_isdigit( $szStr )

Alias

isdigit()

Parameters
NameTypeDescription
$szStr string String to process (1st character only)
Return

(bool) true if $szStr[0] is 0 ... 9

Example(s)
echo MISC_CastString( STR_isdigit( '9a' ) );    // "true"
echo MISC_CastString( STR_isdigit( '9'  ) );    // "true"
echo MISC_CastString( STR_isdigit( 'H909' ) );  // "false"
Assertions

MISC_CastString( STR_isdigit( '9a' ) ) === "true" successful

MISC_CastString( STR_isdigit( '9' ) ) === "true" successful

MISC_CastString( STR_isdigit( 'H909' ) ) === "false" successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_IsVowel(): Determines whether the first character of $cChar is a vowel

[ back to function list ]

Syntax

STR_IsVowel( $cChar )

Parameters
NameTypeDescription
$cChar string The string whose 1st character is to be checked
Return

(bool) true if $cChar[0] is a vowel; false otherwise

Assertions

STR_IsVowel( 'Hello' ) === false successful

STR_IsVowel( 'admittance' ) === true successful

STR_IsVowel( 'À demain' ) === true successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_IsConsonant()

STR_iTran(): Transforms every occurrence of $szToReplace by $szReplacement in $szString (case insensitive)

[ back to function list ]

Syntax

STR_iTran( $szString,$szToReplace,$szReplacement )

Alias

STR_iTran()

Parameters
NameTypeDescription
$szString string string to process
$szToReplace string substring to replace with
$szReplacement string $szReplacement substition string for $szToReplace
Return

(string) the transformed string

Assertions

STR_iTran( 'HeLLo World','l','' ) === 'Heo Word' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_iTran()

STR_Keep(): Keeps only the characters of $szStr which can be found in $szChars

[ back to function list ]

Uses

STR_Pos()

Syntax

STR_Keep( $szStr,$szChars )

Parameters
NameTypeDescription
$szStr string Input string
$szChars string List of chars to keep
Return

(string) The resulting string

Example Executed
echo '<p>',STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ),'</p>';

ueoieauiiia

Assertions

STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) === 'ueoieauiiia' successful

STR_IsVowel( STR_Keep( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) ) successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_Eliminate()

STR_Last(): Determines the $iLength last characters of $szStr

[ back to function list ]

Syntax

STR_Last( $szStr,$iLength )

Parameters
NameTypeDescription
$szStr string String to process
$iLength int Optional length. 1 by default.
Return

(string) The $iLength last characters of $szStr

Example(s)
echo STR_LastPos( '/index.php;/Index.php','/' ); // Prints 11
Assertions

STR_LastPos( '/index.php;/Index.php','/' ) === 11 successful

STR_LastPos( '/index.php;/Index.php','Hello' ) === -1 successful

STR_LastPos( '/index.php','/' ) === 0 successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_LastPos(): Finds the position of the last occurrence of a substring in a string

[ back to function list ]

Syntax

STR_LastPos( $szStr,$szSubStr )

Parameters
NameTypeDescription
$szStr string the string to be searched
$szSubStr string the substring to look for
Return

(int) -1 if $szSubStr not found in $szStr; otherwise it indicates the last position where $szSubStr is found in $szStr

Example(s)
echo STR_LastPos( '/index.php;/Index.php','/' ); // Prints 11
Assertions

STR_LastPos( '/index.php;/Index.php','/' ) === 11 successful

STR_LastPos( '/index.php;/Index.php','Hello' ) === -1 successful

STR_LastPos( '/index.php','/' ) === 0 successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_Left(): Returns the $iCount leftmost characters of $szStr

[ back to function list ]

Syntax

STR_Left( $szStr,$iCount )

Alias

strleft()

Parameters
NameTypeDescription
$szStr string the string to process
$iCount int specifies the number of characters returned from the character expression. This parameter is optional. If $iCount is not specified, only the leftmost character of $szStr is returned.
Return

(string) the $iCount leftmost characters of $szStr

Assertions

STR_Left( 'Hello World',5 ) === 'Hello' successful

STR_Left( 'Hello World' ) === 'H' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_Right()

STR_MatchingWords(): Return all words that are close to $szWord from a character perspective (not meaning). In general it contains a number of collisions that can be quickly disregarded based on their ranking. The function returns an XML string

[ back to function list ]

Warning

Only French words are treated so far (22-07-16 11:26:01)

Syntax

STR_MatchingWords( $szWord,$szLang,$iRequiredRank )

Parameters
NameTypeDescription
$szWord string The word whose siblings must be returned
$szLang string Optional. The language to consider (only French for the time being - 22-07-16 11:26:27)
$iRequiredRank int Optional. The ranking filter (every word whose ranking is lower or equal to $iRequiredRank will be returned in the XML)
Return

(string) an XML string that lists all siblings

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_Minify(): Extracts the start and stop position of the classes contained in a source code

[ back to function list ]

Syntax

STR_Minify( $szStr,$szKeyword )

Parameters
NameTypeDescription
$szStr string The source code string to process. Passed by reference but NOT touched.
$szKeyword string Keyword to look for. Optional. 'class' by default.
Return

(array) An array of start and stop position per class

Example Executed
echo "<p></p>The source code below is a fake and incorrect one!!!</p>";
$szSrcCode = <<< MSG
class MyClass
/*---------*/
{
    public class = 'Anything';    /* {*property class is something weird *} */

    public function Aclass()
    /*--------------------*/
    {
        echo __METHOD__;
    }
}

class MyOtherClass
/*--------------*/
{
    public class = 'Anything';    /* {*property class is something weird *} */

    public function Bclass()
    /*--------------------*/
    {
        echo __METHOD__;
    }
}

interface LSSentanaiInterface
/*=========================*/
{
    /* ====================================================================== */
    /** {{*PopulateFromXMLNode( oXPath,oNode )=

        Populates an object with values stored in the XML file (data storage).
        Current node is considered.

        {*params
            oXPath     (LSXPath)   The XPath object
            oNode      (DOMNode)   A DOMNode object that will be used to obtain
                                    the inner values
        *}

        {*return
            (bool)  [c]true[/c] if object successfully populated; [c]false[/c]
                    otherwise.
        *}

        *}}
     */
    /* ====================================================================== */
    public function PopulateFromXMLNode( oXPath,oNode );
    public function ThrowUp();
    public function __toString();
}   /* End of LSSentanaiInterface interface */

MSG;
echo $szSrcCode;

$aPositions = STR_aClasses( $szSrcCode );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 2  && 
                            ( $aPositions[0][0] === 0   && $aPositions[0][1] === 215 ) &&
                            ( $aPositions[1][0] === 220 && $aPositions[1][1] === 445 ),
                            'ASSERTION SUCCESSFUL: positions of classes correcty determined',
                            'ASSERTION FAILURE: incorrect detection of classes'              ,
                            'GuideAssert' );
$aPositions = STR_aClasses( $szSrcCode,'prelude' );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 0                                                  ,
                            'ASSERTION SUCCESSFUL: positions of prelude structures correcty determined' ,
                            'ASSERTION FAILURE: incorrect detection of preludes'                        ,
                            'GuideAssert' );
$aPositions = STR_aClasses( $szSrcCode,'interface' );
var_dump( $aPositions );
echo LSUnitTesting::assert( count( $aPositions ) === 1  &&
                            ( $aPositions[0][0] === 450 && $aPositions[0][1] === 1360 )                     ,
                            'ASSERTION SUCCESSFUL: positions of interface structures correcty determined'   ,
                            'ASSERTION FAILURE: incorrect detection of interfaces'                          ,
                            'GuideAssert' );


The source code below is a fake and incorrect one!!!

class MyClass /*---------*/ { public class = 'Anything'; /* {*property class is something weird *} */ public function Aclass() /*--------------------*/ { echo __METHOD__; } } class MyOtherClass /*--------------*/ { public class = 'Anything'; /* {*property class is something weird *} */ public function Bclass() /*--------------------*/ { echo __METHOD__; } } interface LSSentanaiInterface /*=========================*/ { /* ====================================================================== */ /** {{*PopulateFromXMLNode( oXPath,oNode )= Populates an object with values stored in the XML file (data storage). Current node is considered. {*params oXPath (LSXPath) The XPath object oNode (DOMNode) A DOMNode object that will be used to obtain the inner values *} {*return (bool) [c]true[/c] if object successfully populated; [c]false[/c] otherwise. *} *}} */ /* ====================================================================== */ public function PopulateFromXMLNode( oXPath,oNode ); public function ThrowUp(); public function __toString(); } /* End of LSSentanaiInterface interface */
D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:59:
array (size=2)
  0 => 
    array (size=2)
      0 => int 0
      1 => int 215
  1 => 
    array (size=2)
      0 => int 220
      1 => int 445

GuideAssert() ... ASSERTION SUCCESSFUL: positions of classes correcty determined

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:67:
array (size=0)
  empty

GuideAssert() ... ASSERTION SUCCESSFUL: positions of prelude structures correcty determined

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code:73:
array (size=1)
  0 => 
    array (size=2)
      0 => int 450
      1 => int 1360

GuideAssert() ... ASSERTION SUCCESSFUL: positions of interface structures correcty determined

Unit Testing

3 assertions: 3 successful; 0 failed

STR_nl2br(): Inserts HTML line breaks before all newlines in a string

[ back to function list ]

Created: 31/08/2013 12:37

Since version 5.4.0013

Author

Syntax

STR_nl2br( $szString,$szBR )

Parameters
NameTypeDescription
$szString string The string whose "\r\n", "\n\r", "\n" or "\r" must be transformed into line breaks
$szBR string The mark that represents a line break. Optional. "<br />" by default.
Return

(string) $szString with all "\r\n", "\n\r", "\n" or "\r" turned to $szBR

Example(s)
$szTooltip = STR_nl2br( trim( STR_Left( STR_Reduce( strip_tags( $szStr ),' ' ),50 ) ),'' );
echo "<p title=\"{$szTooltip}\">blahblahblah</p>";
Example Executed
$szStr =    "<html>\n"                                  .
                "<head>\n\r"                            .
                    "<title>My first page</title>\r\n"  .
                    "<body>\r"                          .
                        "<h1>My title</h1>\n"           .
                        "<p>My text</p>\n"              .
                    "</body>\n"                         .
                "</head>\n"                             .
            "</html>\r";
echo htmlentities( $szStr );
echo '<hr />';
echo wordwrap( htmlentities( $szResult = STR_nl2br( $szStr ) ) );
echo LSUnitTesting::assert( substr_count( $szResult,'<br />' ) === 9                    ,
                            'ASSERTION SUCCESSFUL: line breaks successfully counted'    ,
                            'ASSERTION FAILURE: invalid line breaks count'              ,
                            'GuideAssert' );

<html>
<head>

<title>My first page</title>
<body>
<h1>My title</h1>
<p>My text</p>
</body>
</head>
</html>

<html><br /><head><br /><title>My first page</title><br /><body><br /><h1>My title</h1><br /><p>My text</p><br /></body><br /></head><br /></html><br />

GuideAssert() ... ASSERTION SUCCESSFUL: line breaks successfully counted

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Null(): Returns a null (ALWAYS)

[ back to function list ]

Remark

This function can be used with nested functions to get rid of a return value. See also MISC_true() and MISC_false().

Syntax

STR_Null( $x )

Parameters
NameTypeDescription
$x mixed Whatever is sent
Return

(null) always null

Example Executed
if ( is_null( STR_Null( 'Hello World' ) ) )
{
    echo "Got a null";
}

Got a null
Assertions

is_null( STR_Null( 1878 ) ) successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Tao()

STR_o(): Transforms 'o' variations (uppercase and lowercase) into 'o' equivalent

[ back to function list ]

Syntax

STR_o( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'o' variations (Øòóôõö) (uppercase and lowercase) turned to 'o'

Example(s)
echo STR_o( "Ô, que c'est drôle!" );    // Prints "o, que c'est drole!"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_o2(): Transforms 'o' entities (uppercase and lowercase) into 'o' equivalent

[ back to function list ]

Syntax

STR_o2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'o' entities (uppercase and lowercase) turned to 'o'

Example(s)
echo STR_o2( "&Ocirc;, que c'est dr&ocirc;le!" );    // Prints "o, que c'est drole!"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_padl(): Left padding of a string

[ back to function list ]

Syntax

STR_padl( $szStr,$iLength,$szPadding )

Parameters
NameTypeDescription
$szStr string String to pad
$iLength int Length of resulting string
$szPadding string Padding character. Optional. By default ' '.
Return

(string) The resulting string, left padded with $szPadding

Example(s)
echo STR_padl( '101',6,'0' );  // '000101'
echo STR_padl( '101',6     );  // '   101'
Assertions

STR_padl( '101',6,'0' ) === '000101' successful

STR_padl( '101',6 ) === ' 101' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_padr()

STR_padr(): Right padding of a string

[ back to function list ]

Syntax

STR_padr( $szStr,$iLength,$szPadding )

Parameters
NameTypeDescription
$szStr string String to pad
$iLength int Length of resulting string
$szPadding string Padding character. Optional. By default ' '.
Return

(string) The resulting string, right padded with $szPadding

Example(s)
echo STR_padr( '101',6,'0' );  // '101000'
echo STR_padr( '101',6     );  // '101   '
Assertions

STR_padr( '101',6,'0' ) === '101000' successful

STR_padr( '101',6 ) === '101 ' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_padl()

STR_PasswordStrength(): Checks the strength of a password

[ back to function list ]

Created: 06/08/2013 08:15

Author

Syntax

STR_PasswordStrength( $szPwd )

Parameters
NameTypeDescription
$szPwd string The password to check
Return

(int) A strength index (0 = very weak; 10 = strong)

Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_Peek(): Returns the ASCII code of a given character in a string.

[ back to function list ]

Created: 19/09/2013 19:15

Author

Syntax

STR_Peek( $szString,$iPosition )

Parameters
NameTypeDescription
$szString string String to process.
$iPosition int Position in string ($szString) to examine
Return

(int) ASCII code value of the character found at $iPosition in $szString.

Example(s)
echo STR_Peek( "Hello",0 );     // 72 because 'H' is 72 ASCII
Assertions

STR_Peek( "Hello",0 ) === 72 successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Poke()

STR_PluralToSingular(): Get the singular form of a word

[ back to function list ]

Warning

This function is experimental. Do not use in production environments. Moreover, it only codes the plurals to singulars in French.

Syntax

STR_PluralToSingular( $szWord,$szLang )

Parameters
NameTypeDescription
$szWord string The word to obtain the singular form of
$szLang string Optional language. fr by default.
Return

(string) Singular form of $szWord

Example Executed
echo '<p>',STR_PluralToSingular( 'flûtiaux' ),'</p>';

flûtial

Assertions

STR_PluralToSingular( 'bureaux' ) === 'bureau' successful

STR_PluralToSingular( 'eaux' ) === 'eau' successful

STR_PluralToSingular( 'flûtiaux' ) === 'flûtiau' failure

STR_PluralToSingular( 'dieux' ) === 'dieu' successful

STR_PluralToSingular( 'feux' ) === 'feu' successful

STR_PluralToSingular( 'trous' ) === 'trou' successful

STR_PluralToSingular( 'demoiselle' ) === 'demoiselle' successful

STR_PluralToSingular( 'chevaux' ) === 'cheval' successful

STR_PluralToSingular( 'éventails' ) === 'éventail' successful

STR_PluralToSingular( 'matières' ) === 'matière' successful

STR_PluralToSingular( 'noms' ) === 'nom' successful

STR_PluralToSingular( 'abstraits' ) === 'abstrait' successful

STR_PluralToSingular( 'objets' ) === 'objet' successful

STR_PluralToSingular( 'funérailles' ) === 'funéraille' successful

STR_PluralToSingular( 'montagnes' ) === 'montagne' successful

STR_PluralToSingular( 'avons' ) === 'avons' failure

STR_PluralToSingular( 'enzymes' ) === 'enzyme' successful

STR_PluralToSingular( 'enverrons' ) === 'enverrons' failure

STR_PluralToSingular( 'envoyâmes' ) === 'envoyâmes' successful

STR_PluralToSingular( 'envoyâtes' ) === 'envoyâtes' successful

STR_PluralToSingular( 'enverras' ) === 'enverras' failure

STR_PluralToSingular( 'envoyions' ) === 'envoyions' failure

STR_PluralToSingular( 'ions' ) === 'ion' successful

STR_PluralToSingular( 'avions' ) === 'avion' successful

STR_PluralToSingular( 'envoies' ) === 'envoies' failure

STR_PluralToSingular( 'bijoux' ) === 'bijou' successful

STR_PluralToSingular( 'cailloux' ) === 'caillou' successful

STR_PluralToSingular( 'peux' ) === 'peux' failure

STR_PluralToSingular( 'veux' ) === 'veux' failure

STR_PluralToSingular( 'voeux' ) === 'voeu' successful

STR_PluralToSingular( 'dix' ) === 'dix' failure

Unit Testing

31 assertions: 22 successful; 9 failed

See Also

STR_SingularToPlural()

STR_Poke(): Poke a character at given position in a string.

[ back to function list ]

Created: 19/09/2013 19:15

Author

Syntax

STR_Poke( $szString,$iPosition,$iCode )

Parameters
NameTypeDescription
$szString string string to process.
$iPosition int position in string ($szString) to poke
$iCode int code to stuff at the proper position
Return

(string) Resulting string

Example(s)
$szString = "Hello";
echo STR_poke( $szString,1,97 );    // "Hallo"
echo $szString;                     // "Hello"
Assertions

STR_poke( 'Hello',1,97 ) === 'Hallo' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Peek()

STR_Pos(): Finds the position of first occurrence of a string (case sensitive)

[ back to function list ]

Syntax

STR_Pos( $szStr,$szSubStr,$iStart )

Parameters
NameTypeDescription
$szStr string the string to be searched
$szSubStr string the substring to look for
$iStart int Optional offset parameter to specify where searching must start. 0 by default.
Return

(int) -1 if $szSubStr not found in $szStr; otherwise it indicates the 1st position where $szSubStr is found in $szStr

Example(s)
echo STR_Pos( 'Hello World','d' ); // Prints 10
Assertions

STR_Pos( 'Hello','l' ) === 2 successful

STR_Pos( 'HeLlo','l' ) === 3 successful

STR_Pos( 'HeLlo','pa' ) === -1 successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_iPos()

STR_Random(): Generates string at random

[ back to function list ]

Created: 14/10/2013 06:49

Author

Syntax

STR_Random( $iLength,$iStrategy )

Parameters
NameTypeDescription
$iLength int Length of the string to be generated. By default $iLength is 15 characters long.
$iStrategy int Strategy when generating the string. By default digits are returned.
StrategyDescription
0digits only (default)
1uppercase letters only
2lowercase letters only
Return

(string) string at random

Example Executed
echo '<p>',$szRandom1 = STR_Random( 40 ),'</p>';
echo '<p>',$szRandom2 = STR_Random( 15,1 ),'</p>';
echo '<p>',$szRandom3 = STR_Random( 40,2 ),'</p>';

echo LSUnitTesting::assert( strlen( $szRandom1 ) === 40                             ,
                            'ASSERTION SUCCESSFUL: correct length for $szRandom1'   ,
                            'ASSERTION FAILURE: incorrect length for $szRandom1'    ,
                            'GuideAssert' );
echo LSUnitTesting::assert( STR_dionly( $szRandom1 ) === $szRandom1                 ,
                            'ASSERTION SUCCESSFUL: $szRandom1 only digits'          ,
                            'ASSERTION FAILURE: $szRandom1 not digits only'         ,
                            'GuideAssert' );
echo LSUnitTesting::assert( strlen( $szRandom2 ) === 15                             ,
                            'ASSERTION SUCCESSFUL: correct length for $szRandom2'   ,
                            'ASSERTION FAILURE: incorrect length for $szRandom2'    ,
                            'GuideAssert' );
echo LSUnitTesting::assert( strtoupper( $szRandom2 ) === $szRandom2                 ,
                            'ASSERTION SUCCESSFUL: $szRandom2 only uppercase'       ,
                            'ASSERTION FAILURE: $szRandom2 NOT only uppercase'      ,
                            'GuideAssert' );
echo LSUnitTesting::assert( strtolower( $szRandom3 ) === $szRandom3                 ,
                            'ASSERTION SUCCESSFUL: $szRandom3 only lowercase'       ,
                            'ASSERTION FAILURE: $szRandom3 NOT only lowercase'      ,
                            'GuideAssert' );

4381311014854674549143166568144844513936

VVEBAKOJIVHREWE

imhpqhdjeboavnurygrugqfixxfhayrjbxfyndon

GuideAssert() ... ASSERTION SUCCESSFUL: correct length for $szRandom1

GuideAssert() ... ASSERTION SUCCESSFUL: $szRandom1 only digits

GuideAssert() ... ASSERTION SUCCESSFUL: correct length for $szRandom2

GuideAssert() ... ASSERTION SUCCESSFUL: $szRandom2 only uppercase

GuideAssert() ... ASSERTION SUCCESSFUL: $szRandom3 only lowercase

Unit Testing

5 assertions: 5 successful; 0 failed

See Also

STR_GeneratePassword()

STR_Reduce(): Reduces consecutive occurrences of the same character to only 1 occurrence

[ back to function list ]

Syntax

STR_Reduce( $szStr,$cChar )

Parameters
NameTypeDescription
$szStr string string to process
$cChar char character to reduce to 1 consecutive occurrence. Optional. ' ' by default.
Return

(string) resulting string

Example(s)
echo '"' . trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) . '"';
Assertions

trim( STR_Reduce( STR_Replicate( " Hello ",5 ),' ' ) ) === "Hello Hello Hello Hello Hello" successful

STR_Reduce( "Hello",'l' ) === "Helo" successful

STR_Reduce( "c://somedir//somefolder//hello.txt",'/' ) === "c:/somedir/somefolder/hello.txt" successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_Replicate(), STR_Reduce2()

STR_Reduce2(): Reduces consecutive occurrences of the same character to only 1 occurrence

[ back to function list ]

Syntax

STR_Reduce2( $szStr )

Parameters
NameTypeDescription
$szStr string string to process
Return

(string) resulting string

Example(s)
echo '"' . trim( STR_Reduce( STR_Replicate( "     Hello     ",5 ),' ' ) ) . '"';
Assertions

trim( STR_Reduce( STR_Replicate( " Hello ",5 ),' ' ) ) === "Hello Hello Hello Hello Hello" successful

STR_Reduce( "Hello",'l' ) === "Helo" successful

STR_Reduce( "c://somedir//somefolder//hello.txt",'/' ) === "c:/somedir/somefolder/hello.txt" successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_Replicate(), STR_Reduce2()

STR_RemovePHPComments(): Remove PHP Comments from a string (which is supposed to be PHP Code)

[ back to function list ]

Created: 01/04/2015 08:57

Author

Syntax

STR_RemovePHPComments( $szStr )

Parameters
NameTypeDescription
$szStr string String to process.
Return

(string) $szStr where all PHP comments have been removed

Example Executed
$szSrc      = 'C:/websites/vaesoli.org/www/httpdocs/vaesoli/include/LSStrings.functions.php';
$szCode     = file_get_contents( $szSrc );
$szClean    = STR_RemovePHPComments( $szCode );

if ( defined( 'T_DOC_COMMENT' ) )
{
    $aCommentTokens[] = T_DOC_COMMENT; // PHP 5
}
if ( defined( 'T_ML_COMMENT'  ) )
{
    $aCommentTokens[] = T_ML_COMMENT;  // PHP 4
}

$aCodeTokens = token_get_all( $szClean );
$bFoundComments = false;

foreach ( $aCodeTokens as $token )
{
    if ( is_array( $token ) )
    {
        if ( in_array( $token[0],$aCommentTokens ) )
        {
            $bFoundComments = true;
            var_dump( $token );
            break;
        }
    }
}

echo LSUnitTesting::assert( ! $bFoundComments                                       ,
                            'ASSERTION SUCCESSFUL: all comments seem to be removed' ,
                            'ASSERTION FAILURE: there are still comments!'          ,
                            'GuideAssert' );


( ! ) Warning: file_get_contents(C:/websites/vaesoli.org/www/httpdocs/vaesoli/include/LSStrings.functions.php): failed to open stream: No such file or directory in D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code on line 2
Call Stack
#TimeMemoryFunctionLocation
10.0041778344{main}( )...\guide.php:0
20.06235746824LSDocMaker->Doc( )...\guide.php:426
30.06235763720LSDocMaker->DocumentSourceFile( )...\guide.php:621
40.06546699320LSDocMaker->DocumentFunctionSourceFile( )...\guide.php:694
50.55889107184LSFunction->RenderExecs( )...\guide.php:869
60.55909112304eval( '$szSrc = 'C:/websites/vaesoli.org/www/httpdocs/vaesoli/include/LSStrings.functions.php'; $szCode = file_get_contents( $szSrc ); $szClean = STR_RemovePHPComments( $szCode ); if ( defined( 'T_DOC_COMMENT' ) ) { $aCommentTokens[] = T_DOC_COMMENT; // PHP 5 } if ( defined( 'T_ML_COMMENT' ) ) { $aCommentTokens[] = T_ML_COMMENT; // PHP 4 } $aCodeTokens = token_get_all( $szClean ); $bFoundComments = false; foreach ( $aCodeTokens as $token ) { if ( is_array( $token ) ) { if ( in_array( $token[0],$aCommentTokens ) ) { $bFoundComments = true; var_dump( $token ); break; } } } echo LSUnitTesting::assert( ! $bFoundComments , 'ASSERTION SUCCESSFUL: all comments seem to be removed' , 'ASSERTION FAILURE: there are still comments!' , 'GuideAssert' );' )...\LSFunction.class.php:211
70.55909112416file_get_contents ( )...\LSFunction.class.php(211) : eval()'d code:2

GuideAssert() ... ASSERTION SUCCESSFUL: all comments seem to be removed

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_StripPHPTags(), STR_StripTags()

STR_RemoveStartingSlash(): Removes starting slash from $szStr only if leftmost character of $szStr is a slash ($szChar, defaulted to '/').

[ back to function list ]

Warning

$szChar should be a single character for the function to work as expected and documented. Make sure you do not pass an empty string ($szStr )

Syntax

STR_RemoveStartingSlash( $szStr,$szChar )

Parameters
NameTypeDescription
$szStr string Input string
$szChar char Slash character. Optional. '/' by default.
Return

(string) The resulting string

Example(s)
// Example #1
$szBase = 'http://www.latosensu.be/articles/';
$szURL  = '/core/php/strings.php';
echo STR_AddSlash( $szBase ) . STR_RemovesStartingSlash( $szURL );
// Prints 'http://www.latosensu.be/articles/core/php/strings.php'

// Example #2
$szBase = 'http://www.latosensu.be/articles';
$szURL  = 'core/php/strings.php';
echo STR_AddSlash( $szBase ) . STR_RemovesStartingSlash( $szURL );
// Prints 'http://www.latosensu.be/articles/core/php/strings.php'
Assertions

STR_RemoveStartingSlash( '/sitemap.php' ) === 'sitemap.php' successful

STR_RemoveStartingSlash( 'sitemap.php' ) === 'sitemap.php' successful

STR_RemoveStartingSlash( 'sitemap.php','s' ) === 'itemap.php' successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_Replicate(): Replicates a string

[ back to function list ]

Remark

This is merely a wrapper around PHP built-in function str_repeat(). The STR_Copy() alias defines the $iTimes parameter as 2 by default.

Syntax

STR_Replicate( $szStr,$iTimes )

Alias

STR_Copy()

Parameters
NameTypeDescription
$szStr string the string to be repeated
$iTimes int number of times to repeat $szStr
Return

(string) resulting string

Example(s)
echo STR_Replicate( 'me',3 ); // Prints 'mememe'
Assertions

STR_Replicate( 'me',3 ) === 'mememe' successful

STR_Copy( 'copy-me' ) === 'copy-mecopy-me' successful

Unit Testing

2 assertions: 2 successful; 0 failed

STR_Right(): Returns the $iCount rightmost characters of $szStr

[ back to function list ]

Modified: 14/10/2013 07:17

Author

Syntax

STR_Right( $szStr,$iCount )

Alias

strright(), STR_Last()

Parameters
NameTypeDescription
$szStr string the string to process
$iCount int specifies the number of characters returned from the character expression. This parameter is optional. If $iCount is not specified, only the leftmost character of $szStr is returned.
Return

(string) the $iCount rightmost characters of $szStr

Assertions

STR_Right( 'Hello World',5 ) === 'World' successful

STR_Right( 'Hello World' ) === 'd' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_Left()

STR_shl(): Shifts-Left a string by a given number of bits ($nBits).

[ back to function list ]

Remark

STR_shl() can be one useful component of an encryption algorithm.

Syntax

STR_shl( $szStr,$nBits )

Parameters
NameTypeDescription
$szStr string The string that must be left shifted
$nBits int Number of bits to shift the string by. Minimum 1 bit, maximum 7 bits.
Return

(string) $szStr left-shifted by $nBits

Example(s)
echo '<p>Shifted left: ' . ( $szLShifted = STR_shl( 'Hello',3 ) ) . '</p>'; // Prints 'C+ccz'
echo '<p>Shifted back to right: ' . STR_shr( $szLShifted,3 ) . '</p>';      // Prints 'Hello'
Assertions

STR_shl( 'Hello',3 ) === 'C+ccz' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_shr()

STR_shr(): Shifts-Right a string by a given number of bits ($nBits).

[ back to function list ]

Remark

STR_shr() can be one useful component of an encryption algorithm.

Syntax

STR_shr( $szStr,$nBits )

Parameters
NameTypeDescription
$szStr string The string that must be right shifted
$nBits int Number of bits to shift the string by. Minimum 1 bit, maximum 7 bits.
Return

(string) $szStr right-shifted by $nBits

Example(s)
echo '<p>Shifted left: ' . ( $szLShifted = STR_shl( 'Hello',3 ) ) . '</p>'; // Prints 'C+ccz'
echo '<p>Shifted back to right: ' . STR_shr( $szLShifted,3 ) . '</p>';      // Prints 'Hello'
Assertions

STR_shr( 'C+ccz',3 ) === 'Hello' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_shl()

STR_SingularToPlural(): Get the plural form of a word

[ back to function list ]

Warning

This function is experimental. Do not use in production environments. Moreover, it only codes the plurals to singulars in French.

Syntax

STR_SingularToPlural( $szWord,$szLang )

Parameters
NameTypeDescription
$szWord string The word to obtain the plural form of
$szLang string Optional language. fr by default.
Return

(string) Plural form of $szWord

Assertions

STR_SingularToPlural( 'bureau' ) === 'bureaux' successful

STR_SingularToPlural( 'flûtiau' ) === 'flûtiaux' successful

STR_SingularToPlural( 'eau' ) === 'eaux' successful

STR_SingularToPlural( 'hibou' ) === 'hiboux' successful

STR_SingularToPlural( 'éventail' ) === 'éventails' successful

STR_SingularToPlural( 'travail' ) === 'travaux' successful

STR_SingularToPlural( 'cheval' ) === 'chevaux' successful

Unit Testing

7 assertions: 7 successful; 0 failed

See Also

STR_PluralToSingular()

STR_Soothe(): Soothes a string by inserting one character every character

[ back to function list ]

Syntax

STR_Soothe( $szStr,$cChar )

Parameters
NameTypeDescription
$szStr string The string that must be soothed
$cChar char The character to "slacken" $szStr with. Optional: ' ' by default.
Return

(string) $szStr soothed with $cChar

Example(s)
// If anchor found in User Agent string
if ( preg_match( '%(?P<anchor><a[^>]*>(.*?)</a>)%si',$szUA,$aMatch ) )
{
    // This is the anchor that we detected
    $szAnchor = $aMatch['anchor'];
    // Remove it from the User Agent string (and soothe the anchor)
    $szUA     = str_replace( $szAnchor,'',$szUA ) . ' (anchor removed ... ' . STR_Soothe( $szAnchor,'.' ) . ')';
    // Echo result
    echo "<p>{$szUA}</p>";
}
Assertions

STR_Soothe( 'Hello' ) === 'H e l l o ' successful

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Sort(): Sorts a string

[ back to function list ]

Syntax

STR_Sort( $szStr )

Parameters
NameTypeDescription
$szStr string The string that must be sorted
Return

(string) $szStr soothed with $cChar

Assertions

STR_Sort( 'BOENS' ) === 'BENOS' successful

STR_Sort( 'LATO SENSU MANAGEMENT' ) === ' AAAEEEGLMMNNNOSSTTU' successful

STR_Sort( 'QUITUS' ) === 'IQSTUU' successful

Unit Testing

3 assertions: 3 successful; 0 failed

STR_SquareBracketsToAngleBrackets(): Turns square brackets to angle brackets

[ back to function list ]

Created: 22/09/2013

Since version 5.6.0000

Modified: 14/09/2014 h1,h2,h3 support

Author

Syntax

STR_SquareBracketsToAngleBrackets( $szText )

Alias

STR_FromSquareBracketsToAngleBrackets()

Parameters
NameTypeDescription
$szText string Text to process
Return

(string) Square brackets turned to angle brackets

Assertions

STR_SquareBracketsToAngleBrackets( '[ol][li]...[/li][/ol]' ) === '<ol><li>...</li></ol>' successful

STR_SquareBracketsToAngleBrackets( '[h1][/h1]' ) === '<h1></h1>' successful

STR_SquareBracketsToAngleBrackets( '[h2][/h2]' ) === '<h2></h2>' successful

STR_SquareBracketsToAngleBrackets( '[h3][/h3]' ) === '<h3></h3>' successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

STR_AngleBracketsToSquareBrackets()

STR_SquareBracketsToAngleBracketsEx(): Turns square brackets to angle brackets (extended version: transformation done via regular expressions)

[ back to function list ]

Created: 27/01/2015

Since version 7.0.0001

Author

Syntax

STR_SquareBracketsToAngleBracketsEx( $szText )

Parameters
NameTypeDescription
$szText string Text to process
Return

(string) Square brackets turned to angle brackets

Assertions

STR_SquareBracketsToAngleBracketsEx( '[ol class="menu"][li class="first"][p class="warning" data-editable="true"]Hello[/p][/li][/ol]' ) === '<ol class="menu"><li class="first"><p class="warning" data-editable="true">Hello</p></li></ol>' successful

STR_SquareBracketsToAngleBracketsEx( '[php include(myfile.txt); /php]' ) === '<?php include(myfile.txt); ?>' successful

STR_SquareBracketsToAngleBracketsEx( "[php include(myfile.txt);\n /php]" ) === "<?php include(myfile.txt);\n ?>" successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

STR_SquareBracketsToAngleBrackets()

STR_StartsWith(): Determines if $szStr starts with $szStart

[ back to function list ]

Syntax

STR_StartsWith( $szStr,$szStart )

Alias

STR_StartWith()

Parameters
NameTypeDescription
$szStr string the string to examine
$szStart string the string to look for
Return

(boolean) true if $szStr starts with $szStart

Example(s)
echo MISC_CastString( STR_StartsWith( 'Hello World','Hello' ) ); // Prints 'true'
Assertions

STR_StartsWith( '.php=return (int) date( "d" );','.php=' ) === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_Left(), STR_EndsWith()

STR_StraightenBadEncoding(): Corrects few instances of bad character encoding.

[ back to function list ]

Syntax

STR_StraightenBadEncoding( $szStr )

Parameters
NameTypeDescription
$szStr string String to treat. Passed by reference ... but not touched.
Return

(string) $szStr where some characters are turned to their known equivalent

Example(s)
echo STR_StraightenBadEncoding( 'Célibataire' );  // Prints 'Célibataire'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_Strin(): Returns $szStr amputated from the last character

[ back to function list ]

Syntax

STR_Strin( $szStr,$iRid )

Parameters
NameTypeDescription
$szStr string Input string
$iRid int Number of characters to amputate $szStr from. Optional. 1 by default
Return

(string) The resulting string (length - $iRid characters).

Example(s)
$szFields =
$szValues = '';

foreach( $aFields as $szField => $szValue )  // For each field
{
    $szFields   .= trim( $szField ) . ',';
    $szValues   .= trim( $szValue ) . ',';
}

$szFields = STR_Strin( $szFields );
$szValues = STR_Strin( $szValues );
Assertions

STR_Strin( 'Hello' ) === 'Hell' successful

STR_Strin( 'Hello',2 ) === 'Hel' successful

Unit Testing

2 assertions: 2 successful; 0 failed

STR_stripAccents(): Removes all accents from a string (WordPress implementation)

[ back to function list ]

Syntax

STR_stripAccents( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All accents remived from $szStr

Assertions

STR_aeiouy( 'À demain, ce sera un bel été' ) === 'a demain, ce sera un bel ete' failure

Unit Testing

1 assertions: 0 successful; 1 failed

STR_StripPHPTags(): Strip PHP tags

[ back to function list ]

Created: 03/02/2015 11:52

Author

Syntax

STR_StripPHPTags( $szString )

Parameters
NameTypeDescription
$szString string String to process.
Return

(string) $szString where all PHP tags were removed

Assertions

STR_StripPHPTags( "&lt;?php echo 'Hello'; ?&gt;" ) === '' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_StripTags(), STR_RemovePHPComments()

STR_StripTags(): Strip tags but potentially leave comments

[ back to function list ]

Created: 03/02/2015 11:29

Author

Syntax

STR_StripTags( $szString,$bComments )

Parameters
NameTypeDescription
$szString string String to process.
$bComments bool Optional. true by default, in which case comments will NOT be removed. Use false to remove the HTML/XML comments.
Return

(string) $szString where all tags were removed, potentially accepting the comments (default behavior)

Example(s)
echo STR_StripTags( "<html><head><title>My page</title></head></html>" );
// 'My page'
Assertions

STR_StripTags( "<html><head><title>My page</title></head><body><!-- My comment --></body></html>" ) === 'My page<!-- My comment -->' successful

STR_StripTags( "<html><head><title>My page</title></head><body><!-- My comment --></body></html>",false ) === 'My page' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_StripPHPTags(), STR_RemovePHPComments()

STR_SyntaxColoring(): Syntax coloring of a string

[ back to function list ]

Syntax

STR_SyntaxColoring( $szLine,$aColors )

Parameters
NameTypeDescription
$szLine string The source code string to process. Passed by reference but NOT touched.
$aColors array Associative array of colors that must be used:
$aColors['strings']
$aColors['vars']
$aColors['comments']
Return

(string) $szLine with styling included

Example(s)
$aSyntaxColors              = array();
$aSyntaxColors['vars']      = 'red';
$aSyntaxColors['strings']   = 'blue';
$aSyntaxColors['comments']  = 'rgb(197,98,49)';

echo '<pre>';
echo STR_SyntaxColoring( $szSourceCode,$aSyntaxColors );
echo '</pre>';
Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

STR_Tao(): Simply returns what was given as input

[ back to function list ]

Remark

TAO functions do return what they were given

Syntax

STR_Tao( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) $szStr

Assertions

STR_Tao( 'Hello World' ) === 'Hello World' successful

STR_Tao( 1 ) === '1' successful

STR_Tao( null ) === '' successful

STR_Tao( true ) === 'true' successful

STR_Tao( false ) === 'false' successful

Unit Testing

5 assertions: 5 successful; 0 failed

STR_Tran(): Transforms every occurrence of $szToReplace by $szReplacement in $szString

[ back to function list ]

Syntax

STR_Tran( $szStr,$szToReplace,$szReplacement )

Alias

STR_Tran()

Parameters
NameTypeDescription
$szStr string string to process
$szToReplace string substring to replace with
$szReplacement string $szReplacement substition string for $szToReplace
Return

(string) the transformed string

Assertions

STR_Tran( 'Hello World','l','' ) === 'Heo Word' successful

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

STR_iTran()

STR_u(): Transforms 'u' variations (uppercase and lowercase) into 'u' equivalent

[ back to function list ]

Syntax

STR_u( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'u' variations (ùúûü) (uppercase and lowercase) turned to 'u'

Example(s)
echo STR_u( 'Où êtes-vous?' );    // Prints 'ou êtes-vous?'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_a(), STR_u2(), STR_y(), STR_y2()

STR_u2(): Transforms 'u' entities (uppercase and lowercase) into 'u' equivalent

[ back to function list ]

Syntax

STR_u2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'u' entities (ù ú û ü) (uppercase and lowercase) turned to 'u'

Example(s)
echo STR_u2( "C'est o&ugrave; le mois d'ao&ucirc;t ?" );    // Prints "C'est ou le mois d'aout ?"
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

STR_a2(), STR_e(), STR_e2(), STR_i(), STR_i2(), STR_o(), STR_o2(), STR_a(), STR_u(), STR_y(), STR_y2()

STR_UnEntities(): Transforms all HTML entities into their equivalent characters

[ back to function list ]

Syntax

STR_UnEntities( $szStr )

Alias

unhtmlentities()

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All HTML entities turned to their equivalent characters (e.g. 'é' is turned to 'é')

Example(s)
echo STR_UnEntities( 'Pr&eacute;sident' );    // Prints 'Président'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

STR_Vowels(): Keeps only the vowels of $szStr

[ back to function list ]

Syntax

STR_Vowels( $szStr,$szChars )

Parameters
NameTypeDescription
$szStr string Input string
$szChars string List of chars to keep. Optional.
Return

(string) The resulting string (only the vowels).

Example Executed
echo STR_Vowels( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ); // Prints 'ueoieauiiia'

ueoieauiiia
Assertions

STR_Vowels( 'Rue Bois des Mazuis, 47 - 5070 - Vitrival','aeiouyAEIOUY' ) === 'ueoieauiiia' successful

Unit Testing

1 assertions: 1 successful; 0 failed

STR_y(): Transforms 'y' variations (uppercase and lowercase) into 'y' equivalent

[ back to function list ]

Syntax

STR_y( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(unknown) (string All 'y' variations (uppercase and lowercase) turned to 'y'

Example(s)
echo STR_y( 'ýell' );    // Prints 'yell'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

STR_y2(), STR_a(), STR_a2(), STR_e(), STR_e2()

STR_y2(): Transforms 'y' entities (uppercase and lowercase) into 'y' equivalent

[ back to function list ]

Syntax

STR_y2( $szStr )

Parameters
NameTypeDescription
$szStr string Input string
Return

(string) All 'y' entities (uppercase and lowercase) turned to 'y'

Example(s)
echo STR_y2( '&yacute;ell' );    // Prints 'yell'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

See Also

STR_y(), STR_a(), STR_a2(), STR_e(), STR_e2()

STR_Yranib(): Reverse function of STR_Binary()

[ back to function list ]

Created: 22/04/2014 19:45

Since version 6.0.0006

Author

Syntax

STR_Yranib( $szStr )

Parameters
NameTypeDescription
$szStr string A string that has previously been processed by STR_Binary()
Return

(string) Reversed string

Example Executed
$szBin      = STR_Binary( 'Hello World' );
echo '<p>',$szBin,'</p>';

$szUnBin    = STR_Yranib( $szBin );
echo '<p>',$szUnBin,'</p>';

echo LSUnitTesting::assert( $szUnBin === 'Hello World'                              ,
                            'ASSERTION SUCCESSFUL: string successfully recovered'   ,
                            'ASSERTION FAILURE: string recovery falure'             ,
                            'GuideAssert' );

0100100001100101011011000110110001101111001000000101011101101111011100100110110001100100

Hello World

GuideAssert() ... ASSERTION SUCCESSFUL: string successfully recovered

Assertions

STR_Yranib( STR_Binary( 'My good friend' ) ) === 'My good friend' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

STR_Binary()

Précédent Suivant