PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/kdewebdev-3.5.10/php/function.strtr.html

#
HTML | 320 lines | 320 code | 0 blank | 0 comment | 0 complexity | ed5f98f02a50f4a6f85cf0a2994f6d17 MD5 | raw file
Possible License(s): AGPL-1.0, CC-BY-SA-3.0, GPL-2.0
  1. <HTML
  2. ><HEAD
  3. ><TITLE
  4. >strtr</TITLE
  5. ><META
  6. NAME="GENERATOR"
  7. CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
  8. REL="HOME"
  9. TITLE="PHP Manual"
  10. HREF="index.html"><LINK
  11. REL="UP"
  12. TITLE="String functions"
  13. HREF="ref.strings.html"><LINK
  14. REL="PREVIOUS"
  15. TITLE="strtoupper"
  16. HREF="function.strtoupper.html"><LINK
  17. REL="NEXT"
  18. TITLE="substr_count"
  19. HREF="function.substr-count.html"><META
  20. HTTP-EQUIV="Content-type"
  21. CONTENT="text/html; charset=ISO-8859-1"></HEAD
  22. ><BODY
  23. CLASS="refentry"
  24. BGCOLOR="#FFFFFF"
  25. TEXT="#000000"
  26. LINK="#0000FF"
  27. VLINK="#840084"
  28. ALINK="#0000FF"
  29. ><DIV
  30. CLASS="NAVHEADER"
  31. ><TABLE
  32. SUMMARY="Header navigation table"
  33. WIDTH="100%"
  34. BORDER="0"
  35. CELLPADDING="0"
  36. CELLSPACING="0"
  37. ><TR
  38. ><TH
  39. COLSPAN="3"
  40. ALIGN="center"
  41. >PHP Manual</TH
  42. ></TR
  43. ><TR
  44. ><TD
  45. WIDTH="10%"
  46. ALIGN="left"
  47. VALIGN="bottom"
  48. ><A
  49. HREF="function.strtoupper.html"
  50. ACCESSKEY="P"
  51. >Prev</A
  52. ></TD
  53. ><TD
  54. WIDTH="80%"
  55. ALIGN="center"
  56. VALIGN="bottom"
  57. ></TD
  58. ><TD
  59. WIDTH="10%"
  60. ALIGN="right"
  61. VALIGN="bottom"
  62. ><A
  63. HREF="function.substr-count.html"
  64. ACCESSKEY="N"
  65. >Next</A
  66. ></TD
  67. ></TR
  68. ></TABLE
  69. ><HR
  70. ALIGN="LEFT"
  71. WIDTH="100%"></DIV
  72. ><H1
  73. ><A
  74. NAME="function.strtr"
  75. ></A
  76. >strtr</H1
  77. ><DIV
  78. CLASS="refnamediv"
  79. ><A
  80. NAME="AEN91647"
  81. ></A
  82. ><P
  83. > (PHP 3, PHP 4 )</P
  84. >strtr&nbsp;--&nbsp;Translate certain characters</DIV
  85. ><DIV
  86. CLASS="refsect1"
  87. ><A
  88. NAME="AEN91650"
  89. ></A
  90. ><H2
  91. >Description</H2
  92. >string <B
  93. CLASS="methodname"
  94. >strtr</B
  95. > ( string str, string from, string to)<BR
  96. ></BR
  97. >string <B
  98. CLASS="methodname"
  99. >strtr</B
  100. > ( string str, array replace_pairs)<BR
  101. ></BR
  102. ><P
  103. >&#13; This function returns a copy of <TT
  104. CLASS="parameter"
  105. ><I
  106. >str</I
  107. ></TT
  108. >,
  109. translating all occurrences of each character in
  110. <TT
  111. CLASS="parameter"
  112. ><I
  113. >from</I
  114. ></TT
  115. > to the corresponding character in
  116. <TT
  117. CLASS="parameter"
  118. ><I
  119. >to</I
  120. ></TT
  121. > and returning the result.
  122. </P
  123. ><P
  124. >&#13; If <TT
  125. CLASS="parameter"
  126. ><I
  127. >from</I
  128. ></TT
  129. > and <TT
  130. CLASS="parameter"
  131. ><I
  132. >to</I
  133. ></TT
  134. > are
  135. different lengths, the extra characters in the longer of the two
  136. are ignored.
  137. <TABLE
  138. WIDTH="100%"
  139. BORDER="0"
  140. CELLPADDING="0"
  141. CELLSPACING="0"
  142. CLASS="EXAMPLE"
  143. ><TR
  144. ><TD
  145. ><DIV
  146. CLASS="example"
  147. ><A
  148. NAME="AEN91680"
  149. ></A
  150. ><P
  151. ><B
  152. >Example 1. <B
  153. CLASS="function"
  154. >strtr()</B
  155. > example</B
  156. ></P
  157. ><TABLE
  158. BORDER="0"
  159. BGCOLOR="#E0E0E0"
  160. CELLPADDING="5"
  161. ><TR
  162. ><TD
  163. ><PRE
  164. CLASS="php"
  165. >$addr = strtr($addr, "???", "aao");</PRE
  166. ></TD
  167. ></TR
  168. ></TABLE
  169. ></DIV
  170. ></TD
  171. ></TR
  172. ></TABLE
  173. >
  174. </P
  175. ><P
  176. >&#13; <B
  177. CLASS="function"
  178. >strtr()</B
  179. > can be called with only two
  180. arguments. If called with two arguments it behaves in a new way:
  181. <TT
  182. CLASS="parameter"
  183. ><I
  184. >from</I
  185. ></TT
  186. > then has to be an array that contains
  187. string -&#62; string pairs that will be replaced in the source
  188. string. <B
  189. CLASS="function"
  190. >strtr()</B
  191. > will always look for the
  192. longest possible match first and will *NOT* try to replace stuff
  193. that it has already worked on.
  194. </P
  195. ><P
  196. >&#13; Examples:
  197. <DIV
  198. CLASS="informalexample"
  199. ><A
  200. NAME="AEN91689"
  201. ></A
  202. ><P
  203. ></P
  204. ><TABLE
  205. BORDER="0"
  206. BGCOLOR="#E0E0E0"
  207. CELLPADDING="5"
  208. ><TR
  209. ><TD
  210. ><PRE
  211. CLASS="php"
  212. >$trans = array("hello" =&#62; "hi", "hi" =&#62; "hello");
  213. echo strtr("hi all, I said hello", $trans) . "\n";</PRE
  214. ></TD
  215. ></TR
  216. ></TABLE
  217. ><P
  218. ></P
  219. ></DIV
  220. >
  221. This will show: "hello all, I said hi",
  222. </P
  223. ><DIV
  224. CLASS="note"
  225. ><BLOCKQUOTE
  226. CLASS="note"
  227. ><P
  228. ><B
  229. >Note: </B
  230. >
  231. This optional <TT
  232. CLASS="parameter"
  233. ><I
  234. >to</I
  235. ></TT
  236. > and
  237. <TT
  238. CLASS="parameter"
  239. ><I
  240. >from</I
  241. ></TT
  242. > parameters were added in PHP 4.0.0
  243. </P
  244. ></BLOCKQUOTE
  245. ></DIV
  246. ><P
  247. >&#13; See also <A
  248. HREF="function.ereg-replace.html"
  249. ><B
  250. CLASS="function"
  251. >ereg_replace()</B
  252. ></A
  253. >.
  254. </P
  255. ></DIV
  256. ><DIV
  257. CLASS="NAVFOOTER"
  258. ><HR
  259. ALIGN="LEFT"
  260. WIDTH="100%"><TABLE
  261. SUMMARY="Footer navigation table"
  262. WIDTH="100%"
  263. BORDER="0"
  264. CELLPADDING="0"
  265. CELLSPACING="0"
  266. ><TR
  267. ><TD
  268. WIDTH="33%"
  269. ALIGN="left"
  270. VALIGN="top"
  271. ><A
  272. HREF="function.strtoupper.html"
  273. ACCESSKEY="P"
  274. >Prev</A
  275. ></TD
  276. ><TD
  277. WIDTH="34%"
  278. ALIGN="center"
  279. VALIGN="top"
  280. ><A
  281. HREF="index.html"
  282. ACCESSKEY="H"
  283. >Home</A
  284. ></TD
  285. ><TD
  286. WIDTH="33%"
  287. ALIGN="right"
  288. VALIGN="top"
  289. ><A
  290. HREF="function.substr-count.html"
  291. ACCESSKEY="N"
  292. >Next</A
  293. ></TD
  294. ></TR
  295. ><TR
  296. ><TD
  297. WIDTH="33%"
  298. ALIGN="left"
  299. VALIGN="top"
  300. >strtoupper</TD
  301. ><TD
  302. WIDTH="34%"
  303. ALIGN="center"
  304. VALIGN="top"
  305. ><A
  306. HREF="ref.strings.html"
  307. ACCESSKEY="U"
  308. >Up</A
  309. ></TD
  310. ><TD
  311. WIDTH="33%"
  312. ALIGN="right"
  313. VALIGN="top"
  314. >substr_count</TD
  315. ></TR
  316. ></TABLE
  317. ></DIV
  318. ></BODY
  319. ></HTML
  320. >