3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValorDecimal($linhaDados, $posicaoInicial, $tamanhoCampo, $decimal = 0) { $retorno = ""; $retorno = substr($linhaDados,$posicaoInicial-1 , $tamanhoCampo ); $retorno = trim($retorno); $retorno = str_replace(".","", $retorno); $retorno = str_replace(",",".", $retorno); if ($retorno != "") { $retorno = ltrim($retorno,'0'); if ($retorno == '') { $retorno = '0'; } if ($retorno != 0 && $decimal != 0) { $divisor = str_pad('1', $decimal + 1, '0'); $retorno = round($retorno / $divisor , $decimal); } } return $retorno; } $v = getValorDecimal('000000015565835', 1, 15, 2); $v = str_replace(".",",", $v); $value = $v; $rsp = ""; if($value != ""){ $arrayVirgula = explode(",",trim($value)); if (count($arrayVirgula) > 1) { $rsp = preg_match("/^[0-9\,]+$/", strip_tags(trim($value))); }else{ $rsp = preg_match("/^[0-9\.]+$/", strip_tags(trim($value))); } } echo $rsp;
Output for git.master, git.master_jit, rfc.property-hooks
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:
60.01 ms | 401 KiB | 8 Q