PHP mysqli_fetch_lengths() Function

PHP mysqli_fetch_lengths() function returns the lengths of the columns of the current row in the result set.


array mysqli_fetch_lengths(result);;

mysqli_fetch_lengths() Function Parameter

result :Required parameter. Mention a result set identifier returned by mysqli_query().

mysqli_fetch_lengths() Function Return Value

Return Values :Returns size of each field as array of integer. 0 if an error occurs

mysqli_fetch_lengths() Function Example

$con = mysqli_fetch_lengthst("localhost","user","password","db");

if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();

$sql = "SELECT fname, lname FROM employee";
$sql_result = mysqli_query($con, $sql);

$field_info = mysqli_fetch_row($sql_result);

foreach(mysqli_fetch_lengths($sql_result) as $obj=>$val)
 echo "Field has length : ". $val->name;