I have big Object with protected properties and a property can be an array of other Objects. My goal is to print this entire Object as a single nested array. So I need to convert the object to an array. I’ve tried doing: $result = (array) $object; But this converts only the highest lever object to an ar…
Tag: php
Shipping carrier custom fields validation in Woocommerce checkout page
I have added two custom input fields in the shipping method section by changing the template /genesis-sample/woocommerce/checkout/review-order.php I have also managed to get them conditionally required. Only when the specific radio button is checked, the input fields appear and become required. I am using jQu…
Laravel Jobs Serialization of ‘Closure’ is not allowed
I would like to send Data to a NewsletterStore Job. But it’s failing with the following error. Any suggestions? I also tried to remove the SerializesModels Models trait. Without any success. Error Controller Job Answer Request is not serializable there is a workaround what you are trying to achieve Your…
Split string by last character and save to array?
I have several strings that look like: longname1, anotherlongname2, has1numbers2init3 I would like to use str_split to split off the last character of the strings. Eg: I can get the number alone using substr($string, -1); but need to find an efficient way of retrieving the remainder of the string. I have trie…
Laravel Storage file encoding
I’m trying to save text file as UTF-8 by using Laravel’s Storage facade. Unfortunately couldn’t find a way and it saves as us-ascii. How can I save as UTF-8? Currently I’m using following code to …
SVG icon in twig template
I’m struggling with svg icons. I’m creating menu and to do this I have to use several of svg icons. I already know, that if I want to manipulate colour with help CSS (for example when icon is active/hover) I have to use in HTML <svg> tag not <img src=”path-to-icon.svg”/>. H…
Why is my while loop spitting out the same row 50+ times? PHP
Here is my code: And here is the while loop: This is just returning 50+ of the same row, aka the only row in the database, but it should only return it once? Answer You’re running the query again in each loop. GetLatestUsers should return the statement.
remove duplicate value from multi dimensional array in php
I have csv file, i am reading data from it, i have join all which are randomly matching their rows like brands, customer and soon.., Here i want to remove all duplicate from multi dimensional array which already in array Here you can see how all duplicate values are appending to array: Here is my php code Tha…
PHP get user id in url 4
I want to get the id from my url like below http://localhost/cpanel-ar/stage_one/reports.php?temp=temp_21day How can GET only the “temp”? Answer I assume that you mean this: This will return an array with your get parameters. for example: http:example.com?getparameter=getvalue returns:
yii2 extract messages to db
I’m using trntv/Yii2-starter-kit. How can I extract messages to DB? My config: ‘*’=> [ ‘class’ => ‘yiii18nDbMessageSource’, ‘sourceMessageTable’=>'{{%i18n_source_message}}’, ‘…