PHPize Online / SQLize Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $tests = array( 'LocalBusiness' => 'Local Business', 'CivicStructureBuilding' => 'Civic Structure Building', 'getUserMobilePhoneNumber' => 'Get User Mobile Phone Number', 'bandGuitar1' => 'Band Guitar 1', 'band2Guitar123' => 'Band 2 Guitar 123', 'CustomerIDWithSomeOtherJETWords' => 'Customer ID With Some Other JET Words', 'noOneIsMightierThanI' => 'No One Is Mightier Than I', 'USAIsNumber4' => 'USA Is Number 4', ); foreach ($tests AS $input => $expected) { $output = ucwords( preg_replace( //array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/'), '/([A-Z]{2,}?(?=[A-Z][a-z]+|[^A-Z])|[A-Z]?[a-z]*|\d+)\K(?!$)/', ' ', $input ) ); echo $output .' : '. ($output == $expected ? 'PASSED' : 'FAILED') . PHP_EOL; }
Show:  
Copy Clear