The mysql_fetch_lengths() function is used to get length of the content of each field in a row.
PHP mysql_fetch_lengths() Function Example:
The mysql_fetch_lengths() function is used to get length of the content of each field in a row. In this example, first we will find the row and after that use mysql_fetch_lengths() function to find the content length of a row.
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ mysql_select_db("php_mysql", $connection); $sql = "SELECT * from user"; $result = mysql_query($sql,$connection); echo "Row Value<br/>"; print_r(mysql_fetch_row($result)); echo "<br/>Content Length<br/>"; print_r(mysql_fetch_lengths($result)); } mysql_close($connection); ?>
After running this example the output is:
Output:
Row Value Array ( [0] => 3 [1] => Deepak [2] => deepak@rediffmail.com [3] => Noida ) Content Length Array ( [0] => 1 [1] => 6 [2] => 21 [3] => 5 )
[ 0 ] Comments