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
CREATE TABLE A ( DATA VARCHAR(10) NOT NULL ); INSERT INTO A ( DATA ) VALUES ('a'); INSERT INTO A ( DATA ) VALUES ('b'); SELECT * FROM A;

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

Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $query = "SELECT DATA FROM A;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); extract($row); $a = [['id'=> 1], ['id'=> 2]]; $b = [['id'=> 4], ['id'=> 3]]; print_r(array_uintersect($a, $b, function ($v1, $v2) { if (is_object($v1) && is_object($v2)) { $v1 = (array)$v1; $v2 = (array)$v2; } if (is_array($v1) && is_array($v2)) { $keys1 = array_keys($v1); foreach ($keys1 as $key) { if (!key_exists($key, $v2) || $v2[$key] > $v1[$key]) return -1; // array has different key if ($v2[$key] === $v1[$key]) continue; return 1; // array has same key but unidentical value } return 0; // array is same } if (gettype($v1) == gettype($v2)) { return $v1 <=> $v2; // spaceship operator compare } }));
Copy Clear