Source of: /manual/en/function.mysql-fetch-lengths.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mysql.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.mysql-fetch-lengths.php',
1 => 'mysql_fetch_lengths',
),
'up' =>
array (
0 => 'ref.mysql.php',
1 => 'MySQL Functions',
),
'prev' =>
array (
0 => 'function.mysql-fetch-field.php',
1 => 'mysql_fetch_field',
),
'next' =>
array (
0 => 'function.mysql-fetch-object.php',
1 => 'mysql_fetch_object',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.mysql-fetch-lengths" class="refentry">
<div class="refnamediv">
<h1 class="refname">mysql_fetch_lengths</h1>
<p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_fetch_lengths</span> — <span class="dc-title">Get the length of each output in a result</span></p>
</div>
<a name="function.mysql-fetch-lengths.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">array</span> <span class="methodname"><b>mysql_fetch_lengths</b></span>
( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result</tt></span>
)</div>
<p class="para rdfs-comment">
Returns an array that corresponds to the lengths of each field
in the last row fetched by MySQL.
</p>
<p class="para">
<b>mysql_fetch_lengths()</b> stores the lengths of
each result column in the last row returned by
<a href="function.mysql-fetch-row.php" class="function">mysql_fetch_row()</a>,
<a href="function.mysql-fetch-assoc.php" class="function">mysql_fetch_assoc()</a>,
<a href="function.mysql-fetch-array.php" class="function">mysql_fetch_array()</a>, and
<a href="function.mysql-fetch-object.php" class="function">mysql_fetch_object()</a> in an array, starting at
offset 0.
</p>
</div>
<a name="function.mysql-fetch-lengths.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">
result</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">The result <a href="language.types.resource.php" class="type resource">resource</a> that
is being evaluated. This result comes from a call to
<a href="function.mysql-query.php" class="function">mysql_query()</a>.</p></dd>
</dl>
<p>
</p>
</div>
<a name="function.mysql-fetch-lengths.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
An <a href="language.types.array.php" class="type array">array</a> of lengths on success or <b><tt class="constant">FALSE</tt></b> on failure.
</p>
</div>
<a name="function.mysql-fetch-lengths.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 A <b>mysql_fetch_lengths()</b> example</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT id,email FROM people WHERE id = '42'"</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">'Could not run query: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">();<br /> exit;<br />}<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$lengths </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_fetch_lengths</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$lengths</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
<div class="example-contents para"><p>The above example will output
something similar to:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
Array
(
[id] => 42
[email] => user@example.com
)
Array
(
[0] => 2
[1] => 16
)
</pre></div>
</div>
</div><p>
</p>
</div>
<a name="function.mysql-fetch-lengths.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.mysql-field-len.php" class="function" rel="rdfs-seeAlso">mysql_field_len()</a> - Returns the length of the specified field</li>
<li class="member"><a href="function.mysql-fetch-row.php" class="function" rel="rdfs-seeAlso">mysql_fetch_row()</a> - Get a result row as an enumerated array</li>
<li class="member"><a href="function.strlen.php" class="function" rel="rdfs-seeAlso">strlen()</a> - Get string length</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>