3v4l.org

run code in 300+ PHP versions simultaneously
<?php function trimdata($str, $start = 0, $len = 255, $sep = '|') { if($start == 0 && strlen($str) <= $len) return $str; if(strlen($str) - $start <= $len) return substr($str, $start, $len); if($start >= 0) { $str = substr($str, $start, $len + 1); //In-case the last record is complete $pos = strrpos($str, $sep, -1); $str = substr($str, $start, $pos-$start); } else { } return $str; } $str = "0|11|222|3333|4444|5|6|7|8|9|0"; var_dump($ret = trimdata($str, 3, 10), strlen($ret));
Output for git.master, git.master_jit, rfc.property-hooks
string(7) "22|3333" int(7)

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:
41.48 ms | 401 KiB | 8 Q