skip to Main Content

How to exclude image extension from string place in PHP

I want to replace all the string values from example.com to sample.com excluding the image extension .png, .jpeg, .jpg etc. $body = ' www.example.com, example.com, example.com/hello.html, example.com/logo.png, example.com/yourbaby.php , example.com/newimage.jpg, www.example.com/newimage.jpg'; //values $oldomain = ['example.com','www.']; $newdomain= ['sample.com', '']; $excludeextension =…

VIEW QUESTION

Replace all domain including subdomain name using PHP with Regex

I am using preg_replace or str_replace in PHP to replace all the domain name including www $string = ' https://example.com, https://www.example.com, https://subdomain.example.com '; $olddomain= "example.com"; $newdomain = "stackoverflow.com"; $output = str_replace($olddomain, $newdomain, $string); $output = preg_replace('#(www[.])?[.]' . $olddomain. '#', $newdomain,…

VIEW QUESTION

convert String to json object with wrong string

I have String like "[{'techid':'0128','daPoints':3,'speedingPoints':3,'fleetInspectionPoints':3,'lofPoints':3,'missedTrgModules':null,'fullName':'MANPREET SINGH','safetyInspectPoints':3,'missedTrgPoints':3,'speeding_qty':null,'safetyTotalPoints':21,'atFaultPoints':3,'atFaultAccident':null,'region':'PYEM','supervisor':'AGHATOR OSA','driverAlert':null,'status':'A'}]" need to convert into Json format trying something like this const text = "[{'techid':'0128','daPoints':3,'speedingPoints':3,'fleetInspectionPoints':3,'lofPoints':3,'missedTrgModules':null,'fullName':'MANPREET SINGH','safetyInspectPoints':3,'missedTrgPoints':3,'speeding_qty':null,'safetyTotalPoints':21,'atFaultPoints':3,'atFaultAccident':null,'region':'PYEM','supervisor':'AGHATOR OSA','driverAlert':null,'status':'A'}]"; const myArr = JSON.parse(text); document.getElementById("demo").innerHTML = myArr[0]; But getting error :- Uncaught SyntaxError: Expected property name or…

VIEW QUESTION
Back To Top
Search