String to multidimensional/recursive array in PHP

I have a problem with creating a recursive array with PHP. I need to format this string to a multidimensional array with the dot-separated elements indicating multiple levels of array keys. $str = “…

Without Regex: String Between Quotes?

I’m creating a word-replacement script. I’ve run into a roadblock with ignoring strings between quotes and haven’t been able to find a decent solution here that didn’t involve Regex. I have a working …

Could not decode the JSON string using PHP

I could not convert the JSON string to array using PHP. Here is my code: $edu=$_POST[‘edu’]; echo ($edu); The above line is giving the below output. ‘[{“uname”:”univ1″,”year”:”2017″,”description”:”…

PHP split comma-separated values but retain quotes

I’m trying to split a string that contains comma-separated set of values. This can be achieved simply by using str_getcsv but I have an additional requirement where it falls short of. I need to retain …

PHP: How can I remove from String the last word?

How can I remove, with PHP, the last word from a String? For example the string “Hi, I’m Gian Marco” would become “Hi, I’m Gian”.

How to redact sensitive substring following a specific substring?

I’ve inherited this script where some sensitive information is stored in the database…and I’m wanting to replace it with ******** before it gets saved and presented in a log. I’m using PHP…and the …

How does PHP compare strings with comparison operators?

I’m comparing strings with comparison operators. I needs some short of explanations for the below two comparisons and their result. if(‘ai’ > ‘i’) { echo ‘Yes’; } else { echo ‘No’; } …

How to truncate a string in PHP to the sentence closest to a certain number of characters?

I want to truncate/shorten my string to the sentence closest to a ceratain number of characters. I have a working function, but my function truncate to the word closest to a certaion number of …

php: converting number to alphabet and vice versa

So I have this function: function toAlpha($data){ $alphabet = array(‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’); $alpha_flip = …

Remove non-numeric characters (except periods and commas) from a string

If I have the following values: $var1 = AR3,373.31 $var2 = 12.322,11T How can I create a new variable and set it to a copy of the data that has any non-numeric characters removed, with the …