3v4l.org

run code in 300+ PHP versions simultaneously
<?php class asset { protected $id; function __construct($id) { $this->id = $id; } function getId() { return $this->id; } } $getIdsCode = 'array_walk(count($input), array($asset, "getId"))'; // UPDATE THIS if (strpos($getIdsCode, ';') !== false) die('code should not contain ; !'); $getIdsCode = preg_replace('/\s+/', '', $getIdsCode); echo 'code length '.strlen($getIdsCode)."\n"; $input = array(new asset(10),new asset(20),new asset(30)); echo eval("return $getIdsCode;") . "\n"; $input = array(new asset(40),new asset(50),new asset(60)); echo eval("return $getIdsCode;") . "\n"; ?>

preferences:
42.85 ms | 402 KiB | 5 Q