Similar method list in PHP, MySQL, JS

When developers works across PHP, MySQL, and JavaScript, developers often encounter methods or functions that perform similar operations in different languages. This blog highlights similar methods from these three technologies, providing a comparison of their functionality to help you understand their role in different environments.

List of Similar Method in PHP, MySQL, JS:

Functionality PHP Methods JS Methods MySQL Methods
explode explode() split() -
implode implode() join() -
String Length strlen($str) str.length CHAR_LENGTH(column)
Substring Extraction substr($str, $start, $length) str.substring(start, end) SUBSTRING(column, pos, len)
Array Length count($arr) arr.length COUNT(column)
Replace Substring str_replace(search, replace, str) str.replace(search, replace) REPLACE(column, from, to)
Find Position strpos($str, $search) str.indexOf(search) LOCATE(substr, str)
Round Numbers round($num) Math.round(num) ROUND(num)
Generate Random Numbers rand() or mt_rand() Math.random() RAND()
Get Current Date/Time date() new Date() NOW()
Lowercase Conversion strtolower($str) str.toLowerCase() LOWER(column)
Uppercase Conversion strtoupper($str) str.toUpperCase() UPPER(column)
Remove Whitespace trim($str) str.trim() TRIM(column)
Split String explode(delimiter, $str) str.split(delimiter) -
Join Array implode(delimiter, $arr) arr.join(delimiter) GROUP_CONCAT(column)
Convert to JSON json_encode($data) JSON.stringify(obj) JSON_OBJECT(key, value)
Parse JSON json_decode($jsonStr) JSON.parse(jsonStr) JSON_EXTRACT(json, path)
Check for Substring strpos($str, $substring) !== false str.includes(substring) INSTR(column, substring)
Remove Array Element unset($arr[index]) arr.splice(index, 1) -
Reverse String strrev($str) str.split('').reverse().join('') -
Round Down floor($num) Math.floor(num) FLOOR(num)
Round Up ceil($num) Math.ceil(num) CEIL(num)
Find Minimum Value min($arr) Math.min(...arr) MIN(column)
Find Maximum Value max($arr) Math.max(...arr) MAX(column)
Absolute Value abs($num) Math.abs(num) ABS(column)
Power Calculation pow($base, $exp) Math.pow(base, exp) POW(base, exp)
Check If Array is_array($arr) - Array.isArray(arr)
Array Filter array_filter($arr, callback) arr.filter(callback) -
array merge array_merge($arr1, $arr2) arr1.concat(arr2) -
Sort Array sort($arr) arr.sort() ORDER BY column
Current Timestamp time() Date.now() UNIX_TIMESTAMP()
Replace in Array array_replace($arr, replacements) arr.map(val => val === x ? y : val) -
File Existance is_file(), file_exist(), is_dir(string $filename): bool - LOAD_FILE()