Función mysql_fetch_lengths() de PHP

Definición y uso

La función mysql_fetch_lengths() obtiene la longitud de contenido de cada campo en una fila.

Las filas son devueltas por estas funciones:mysql_fetch_array()mysql_fetch_assoc()mysql_fetch_object() o mysql_fetch_row().

Si tiene éxito, esta función devuelve un array numérico; si hay un error o no hay otras filas, devuelve false.

sintaxis

mysql_fetch_lengths(data)
Parámetros Descripción
data Obligatorio. El puntero de datos a usar. Este puntero de datos es desde mysql_query() Resultados devueltos.

Ejemplo

<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Refsnes'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
print_r(mysql_fetch_lengths($result));
mysql_close($con);
?>

Salida:

Array
(
[0] => Adams
[1] => John
[2] => London
)
Array
(
[0] => 5
[1] => 4
[2] => 6
)