Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| info:myphp:search-and-replace [2026/03/05 08:55] – radeff | info:myphp:search-and-replace [2026/03/05 09:48] (Version actuelle) – radeff | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== PHP, search | + | ====== PHP search |
| + | ===== Version 1 ===== | ||
| + | < | ||
| + | <?php | ||
| + | function replacestring($search, | ||
| + | $srchlen=strlen($search); | ||
| + | if ($srchlen==0) return $subject; | ||
| + | $find = $subject; | ||
| + | while ($find = stristr($find, | ||
| + | $srchtxt = substr($find, | ||
| + | $find=substr($find, | ||
| + | $subject = str_replace($srchtxt, | ||
| + | } | ||
| + | return $subject; | ||
| + | } | ||
| + | |||
| + | $a=" | ||
| + | |||
| + | echo replacestring(" | ||
| + | |||
| + | ?> </ | ||
| + | ===== Version 2 ===== | ||
| < | < | ||
| <?php | <?php | ||