Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $stmt = $mysqli->prepare('SELECT 1 as `asd`,23 as `a`,4 as `bcvbvc`'); $stmt->execute(); $stmt->store_result(); $meta = $stmt->result_metadata(); $fields = $meta->fetch_fields(); $columnNames = array_map(static function (stdClass $field): string { return $field->name; }, $fields); $boundValues = array_fill(0, count($columnNames), null); $refs = []; foreach ($boundValues as &$value) { $refs[] =& $value; } $stmt->bind_result(...$refs); $stmt->fetch(); $values = []; foreach ($boundValues as $v) { $values[] = $v; } var_dump([...$boundValues]);
Copy Clear