How to Convert Camel Case to Snake Case Using PHP

AuthorSumit Dey Sarkar

Pubish Date26 Jan 2023


In this tutorial we will learn how to convert camel case to snake case using php.


Here we see a example to convert a camel case to a snake case in php.

Let's see an example -


How to convert camel case to snake case using php

Here we will convert below texts to snake case from camel case using php.

1)  teknowizeOnlineTutorial

2) iAmAWebDeveloper

3) practiceMakeManPerfect


function camelCaseToSnakeCase($string)
    return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $string));
echo camelCaseToSnakeCase('teknowizeOnlineTutorial');
echo camelCaseToSnakeCase('iAmAWebDeveloper');
echo camelCaseToSnakeCase('practiceMakeManPerfect');







Comments 0

Leave a comment