3v4l.org

run code in 300+ PHP versions simultaneously
<?php $profiles = [ 'entity_weight_boost' => [ 'score_mode' => 'sum', 'functions' => [ [ // Incoming links: k = 100, since it is normal to have a bunch of incoming links 'type' => 'satu', 'weight' => '0.6', 'params' => [ 'field' => 'incoming_links', 'missing' => 0, 'a' => 1 , 'k' => 100 ] ], [ // Site links: k = 20, tens of sites is a lot 'type' => 'satu', 'weight' => '0.4', 'params' => [ 'field' => 'sitelink_count', 'missing' => 0, 'a' => 2, 'k' => 20 ] ], [ // (De)boosting by statement values 'type' => 'term_boost', 'weight' => 0.1, 'params' => [ 'statement_keywords' => [ // Q4167410=Wikimedia disambiguation page 'P31=Q4167410' => -10, // T183510: // Q13442814=scientific article 'P31=Q13442814' => -5, // Q18918145=academic journal article 'P31=Q18918145' => -5, ] ] ] ], ], ]; $overrides = [ 'entity_weight_boost.functions.2.params.statement_keywords' => 'SomeOverride' ]; function setDotted(array $path, &$arg, $val) { $key = array_shift($path); if (!isset($arg[$key])) { return; } if (count($path) === 0) { $arg[$key] = $val; } else { setDotted($path, $arg[$key], $val); } } foreach ( $overrides as $path => $configVar ) { setDotted(explode(".", $path), $profiles, ['a' => 1]); } var_dump($profiles);
Output for 5.6.38, 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(1) { ["entity_weight_boost"]=> array(2) { ["score_mode"]=> string(3) "sum" ["functions"]=> array(3) { [0]=> array(3) { ["type"]=> string(4) "satu" ["weight"]=> string(3) "0.6" ["params"]=> array(4) { ["field"]=> string(14) "incoming_links" ["missing"]=> int(0) ["a"]=> int(1) ["k"]=> int(100) } } [1]=> array(3) { ["type"]=> string(4) "satu" ["weight"]=> string(3) "0.4" ["params"]=> array(4) { ["field"]=> string(14) "sitelink_count" ["missing"]=> int(0) ["a"]=> int(2) ["k"]=> int(20) } } [2]=> array(3) { ["type"]=> string(10) "term_boost" ["weight"]=> float(0.1) ["params"]=> array(1) { ["statement_keywords"]=> array(1) { ["a"]=> int(1) } } } } } }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(1) { ["entity_weight_boost"]=> array(2) { ["score_mode"]=> string(3) "sum" ["functions"]=> array(3) { [0]=> array(3) { ["type"]=> string(4) "satu" ["weight"]=> string(3) "0.6" ["params"]=> array(4) { ["field"]=> string(14) "incoming_links" ["missing"]=> int(0) ["a"]=> int(1) ["k"]=> int(100) } } [1]=> array(3) { ["type"]=> string(4) "satu" ["weight"]=> string(3) "0.4" ["params"]=> array(4) { ["field"]=> string(14) "sitelink_count" ["missing"]=> int(0) ["a"]=> int(2) ["k"]=> int(20) } } [2]=> array(3) { ["type"]=> string(10) "term_boost" ["weight"]=> float(0.1) ["params"]=> array(1) { ["statement_keywords"]=> array(1) { ["a"]=> int(1) } } } } } }

preferences:
190.79 ms | 404 KiB | 180 Q