how to convert camel case to upper english words in php

Use below code to solve:

$String = 'createWebsiteManagementUsers';
$Words = preg_replace('/(?<!\ )[A-Z]/', ' $0', $String);
echo ucwords($Words);

//output will be Create Website Mangement Users

a) You can use ucwords():-

echo ucwords($string);

Output:- https://3v4l.org/sCiEJ

b) In your expected outcome spaces are there, if you want that then do:

echo ucwords(implode(' ',preg_split('/(?=[A-Z])/', 'createWebsiteManagementUsers')));

Output:- https://3v4l.org/v3KUK


try this

$data = preg_split('/(?=[A-Z])/', 'createWebsiteManagementUsers');

$string = implode(' ', $data);

echo ucwords($string);

output will be

Create Website Management Users

Tags:

Php