3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "resource_id_heeelp_lala_klopsiki"; preg_match_all('/(_[\w]{1})/', $string, $matches); if(!empty($matches[0])){ foreach($matches[0] as $key){ $result = substr($key, 1, 1); //result is c print $key.' '.ucfirst($result).'<br />'; //$result1=str_replace($result,'',$key);//now your result1 is apitalize //$result2=ucfirst($result1); //now result2 is Apitalize //$finalresult=$result.$result2; ///now your finalresult is cApitalize preg_replace("_i", ucfirst($result), $string); } } print $string;
Output for 4.3.11 - 5.6.28, 7.0.0 - 7.1.0
_i I<br /> Warning: preg_replace(): No ending delimiter '_' found in /in/QeAU1 on line 13 _h H<br /> Warning: preg_replace(): No ending delimiter '_' found in /in/QeAU1 on line 13 _l L<br /> Warning: preg_replace(): No ending delimiter '_' found in /in/QeAU1 on line 13 _k K<br /> Warning: preg_replace(): No ending delimiter '_' found in /in/QeAU1 on line 13 resource_id_heeelp_lala_klopsiki
Output for hhvm-3.10.0 - 3.12.0
_i I<br /> Warning: No ending delimiter '_' found: [_i] in /in/QeAU1 on line 13 _h H<br /> Warning: No ending delimiter '_' found: [_i] in /in/QeAU1 on line 13 _l L<br /> Warning: No ending delimiter '_' found: [_i] in /in/QeAU1 on line 13 _k K<br /> Warning: No ending delimiter '_' found: [_i] in /in/QeAU1 on line 13 resource_id_heeelp_lala_klopsiki
Output for 4.3.0 - 4.3.10
_i I<br /> Warning: No ending delimiter '_' found in /in/QeAU1 on line 13 _h H<br /> Warning: No ending delimiter '_' found in /in/QeAU1 on line 13 _l L<br /> Warning: No ending delimiter '_' found in /in/QeAU1 on line 13 _k K<br /> Warning: No ending delimiter '_' found in /in/QeAU1 on line 13 resource_id_heeelp_lala_klopsiki