Currently, I am requesting an external web service to get some important information. However, the dates this web services return me are something like this: 16/11/2020 12:00:00 a. m. So, I was in other implementations using a code like this to get the DateTime: But it throws this error: DateTime::__construct(): Failed to parse time string (16/11/2020 12:00:00 am) at position
Tag: string
Replacing part of string with prefix and suffix
I want to make it Texts to replace with is with in braces () or [] and can be found from Table 1 or Table 2. Current approach How to improve the code to skip not-required loop ? Answer There may be a way with one loop that I’ll think on, but since the arrays have the same keys they
String and number in for each
I have this code: Expected result (to put as text in another PHP file): $Avroeger = 8.8; $Bvroeger = 5.5; Actual result: (where the 8.3 and 5.7 are the old values of $Avroeger and $Bvroeger) 8.3 = 8.8; 5.7 = 5.5; Anyone who can help? Thank you in advance! Answer You are doing the appending wrong. Do it as shown
How to find the first occurance of a few different Strings in a String in PHP
I have a String that always starts with many As, Bs or Cs and then at one point changes to Ns, Ss and Ts. I need to find the position where it changes and seperate it there. Now of course the position where to split would be quite easy to find with strpos if it were only one letter, like:
Seperate values from string in between characters in php
I have a string (“$big_string”) in php with is combination of small section of strings(“$string”) like this one “-val1(sec1)-“, for eg : How can I separate values from $big_string to an array-like the val1.. and so on values are between ‘-‘ & ‘(‘ and the sec1… and so on values are beteen ‘(‘ & ‘)-‘ Edit: I received the $big_string
How to split a string at a specific character but not replace that character?
I want to split at every ‘;’ and every ‘{‘ from the string below: It splits at the point of every ‘;’ and ‘{‘ but these characters are also removed which I don’t want. I used explode() function though it splits, but also replace that character. And how to multiple splitting in a string? expected result should look like that.
Looking for the same chars in two strings in PHP
Given two strings, what is the best approach in PHP to retrieve the characters which are in common, and those which are not? For instance, given the two strings: I would like to get something like: I saw there are word similarity functions which return a numeric value. However, I would like to retrieve each single char. My approach would
Transform text coma in an array
I am working with the PayPal API and I am trying to add multiple items to my itemList. My problem is that to make the itemList work, the array needs multiples variables: I am using a loop before, to set-up the items, which I am trying to gather into one variable: It doesn’t work and I think that the problem
Manipulate string to convert it to another string with different format
I have a string in the following form: The first letter is a sort of label, the value is associated with a label. I must manipulate and convert my string to the following: With a simple loop, I created an array $temp: Starting from here, I could eventually loop again to build my new string. Or maybe I could do
php substr() and currency symbol strange output
This is a little bit rude code and I am having this output for this simple string formatting sample. $originalValue is equal for example to “$50.00”; $currency is setted correctly to “$”; $value should be “50.00” but this is the result of the above dd() is: b”£50.00″ ($originalValue is still the same even after the “mb_substr” operation) what I have