function.ps-hyphenate.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 135 行
HTML
135 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Hyphenates a word</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ps-get-value.html">ps_get_value</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ps-include-file.html">ps_include_file</a></div> <div class="up"><a href="ref.ps.html">PS Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.ps-hyphenate" class="refentry"> <div class="refnamediv"> <h1 class="refname">ps_hyphenate</h1> <p class="verinfo">(PECL ps:1.1.1-1.3.5)</p><p class="refpurpose"><span class="refname">ps_hyphenate</span> — <span class="dc-title">Hyphenates a word</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>ps_hyphenate</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$psdoc</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$text</tt></span> )</div> <p class="para rdfs-comment"> Hyphenates the passed word. <b>ps_hyphenate()</b> evaluates the value hyphenminchars (set by <a href="function.ps-set-value.html" class="function">ps_set_value()</a>) and the parameter hyphendict (set by <a href="function.ps-set-parameter.html" class="function">ps_set_parameter()</a>). hyphendict must be set before calling this function. </p> <p class="para"> This function requires the locale category LC_CTYPE to be set properly. This is done when the extension is initialized by using the environment variables. On Unix systems read the man page of locale for more information. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">psdoc</tt></i></span> <dd> <p class="para"> Resource identifier of the postscript file as returned by <a href="function.ps-new.html" class="function">ps_new()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">text</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">text</tt></i> should not contain any non alpha characters. Possible positions for breaks are returned in an array of interger numbers. Each number is the position of the char in <i><tt class="parameter">text</tt></i> after which a hyphenation can take place. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> An array of integers indicating the position of possible breaks in the text or <b><tt>FALSE</tt></b> in case of an error. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Hyphennate a text</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$word </span><span style="color: #007700">= </span><span style="color: #DD0000">"Koordinatensystem"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$psdoc </span><span style="color: #007700">= </span><span style="color: #0000BB">ps_new</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">ps_set_parameter</span><span style="color: #007700">(</span><span style="color: #0000BB">$psdoc</span><span style="color: #007700">, </span><span style="color: #DD0000">"hyphendict"</span><span style="color: #007700">, </span><span style="color: #DD0000">"hyph_de.dic"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$hyphens </span><span style="color: #007700">= </span><span style="color: #0000BB">ps_hyphenate</span><span style="color: #007700">(</span><span style="color: #0000BB">$psdoc</span><span style="color: #007700">, </span><span style="color: #0000BB">$word</span><span style="color: #007700">);<br />for(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700"><</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$word</span><span style="color: #007700">); </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {<br /> echo </span><span style="color: #0000BB">$word</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">];<br /> if(</span><span style="color: #0000BB">in_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$i</span><span style="color: #007700">, </span><span style="color: #0000BB">$hyphens</span><span style="color: #007700">))<br /> echo </span><span style="color: #DD0000">"-"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">ps_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$psdoc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>Ko-ordi-na-ten-sys-tem</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.ps-show-boxed.html" class="function" rel="rdfs-seeAlso">ps_show_boxed()</a></li> <li class="member">locale(1)</li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ps-get-value.html">ps_get_value</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ps-include-file.html">ps_include_file</a></div> <div class="up"><a href="ref.ps.html">PS Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?