3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_internal_encoding('UTF-8'); function get_goods_info($str) { $ret = array(); if (($sharp_pos = strpos($str, '#')) === false) { return false; } $ret['description'] = substr($str, 0, $sharp_pos); $str = substr($str, $sharp_pos + 1); if (($iro_pos = mb_strpos($str, '色')) === false) { return false; } $ret['color'] = str_replace('/', '色 ', ltrim(mb_substr($str, 0, $iro_pos + 1))); $ret['weight'] = ltrim(mb_substr($str, $iro_pos + 1)); return $ret; } var_dump( get_goods_info('光の3原色から選べます# 赤/青/黄色 210g'), get_goods_info('# 茶/カーキ/黄/緑色 100g'), get_goods_info('1色でもOK・なんとなくkgにも対応# 肌色 2.5kg'), get_goods_info('これには# マッチしません ') );
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["description"]=> string(31) "光の3原色から選べます" ["color"]=> string(20) "赤色 青色 黄色" ["weight"]=> string(4) "210g" } array(3) { ["description"]=> string(0) "" ["color"]=> string(33) "茶色 カーキ色 黄色 緑色" ["weight"]=> string(4) "100g" } array(3) { ["description"]=> string(44) "1色でもOK・なんとなくkgにも対応" ["color"]=> string(6) "肌色" ["weight"]=> string(5) "2.5kg" } bool(false)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.14 ms | 402 KiB | 8 Q