Skip to content
Advertisement

Tag: string

How convert this date: “16/11/2020 12:00:00 a. m.” to “2020-11-16 00:00:00” with PHP?

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

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

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

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

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

Advertisement