I’m using Laravel 8 . I’ve saved some array in my database and when I try to read those arrays I just get a single character of it. For example the array in database is [“one”, “two”] and when i write it will just show ‘[‘ instead of ‘one’ in my migration file i did this : and also in
Tag: arrays
PHP echo the lowest value from a list of dynamically generated array
I’m using a Wordpress shopping theme and it displays the products details (price, colors etc) as json scripts, however I need to display at least the price as text. The developer was not very helpful and my php knowledge is limited to none, so I’m hoping this will be an easy/fast fix for someone here. This is the part of
How to sort an Array using If in PHP
I have the following Array which contains data such as: Card, Month and Year. However, I receive it in a disorganized way and I would like to treat these values to follow the pattern. No Card, Year and Month or Month, Card and Year. I tried to use the sort() functions of php, but without success! I would like to
Loop trough and modify JSON response
I am making API request to Google Sheets and I receive this response: Array ( [0] => Array ( [Title] => Hours [January] => 1 [February] => 2 …
How to sort a 2-D array by the values of any specific key in PHP alphabetically?
I’ve got a multidimensional array that I want to sort alphabetically by the values of specific key. Structure of the array is – I wanted to sort the data on basis of key ‘deptt’ alphabetically by the values. My desired output should be like all ‘GTT-HOTELS’ data should shown first then ‘KKT-HOTELS’ – Any ideas how to do this? Hope
send post json with php (curl)
i done search tutorial for send post json with curl .. but for this value i cant find in here.. and my question how to convert to array post json in value if like this, and this my value post json i done try to php array like this but still error maybe someone can help me.. and sory for
Compare array values and selecting specific one
I need a bit of help with the below concept. I have an array: I would like to loop through it and select the “first IN” and “last OUT” based on “dateTime”. So I should be getting: How is it possible to achieve this? Appreciate any help. Thanks, Answer The way I would approach this is to: Filter the RAW
Format simpe array in multidimensional
I have a simple array in PHP like this : I want to convert this array in multidimensional width underscore as separator : I can do this with the following uggly code : How can I do this with a pretty function ? Thanks for reply Answer It’s pretty easy to achieve by iterating and adding branch by branch to
How to add element to advanced array inside foreach loop
I am trying to add my data to my array inside my foreach loop. I have almost done it successfully, except the array is too in-depth. It’s showing array->array->{WHAT I WANT} When I need array->{WHAT I WANT} Example, I’m needing it to be like: When at the moment, it’s showing: The code I’m currently using inside my foreach loop is:
How do I get the last iteration of foreach if the total is unknown
I want to echo a variable at the last iteration of a foreach loop, only counting when a conditional is met inside a loop. I realize I could echo $var outside the foreach statement, but I’d really like to figure out a way to do this within the foreach statement. This a crude example where that makes total sense, but