3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extract_unit($string, $start, $end) { $pos = stripos($string, $start); $str = substr($string, $pos); $str_two = substr($str, strlen($start)); $second_pos = stripos($str_two, $end); $str_three = substr($str_two, 0, $second_pos); $unit = trim($str_three); // remove whitespaces return $unit; } $str = "X_HD01_1"; $str = "X_HD01_1, X_HD0003_2, X_HD12/12/2016/1_01"; $str_array =explode(',',$str); foreach($str_array as $val) { $unit = extract_unit($val, '_', '_'); // Outputs: acronym echo $unit."\n"; }
Output for git.master_jit, git.master, rfc.property-hooks
HD01 HD0003 HD12/12/2016/1

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:
126.36 ms | 405 KiB | 5 Q