Skip to content
Advertisement

Tag: arrays

PHP storing array in database

Soo i have saved a array inn my database using var_export($myarray, true); But when im trying to get the array from the database later i cant figure out how to do it. here is what ive tried now $henl =…

PHP in_array function doesn’t find value

I have this PHP variable: That print this array: Then I have this code to find a value inside of that array: But all the time it returns “Isn’t in array” Also I’ve tried to convert my original variable with: But also I’m getting the same return. Answer You have a multi-dimensional array, so just extract the 0 columns with

Create Array From Key

Thank you in advance. Is there any way to create a multidimensional array from key names. Transform to this array. Thank you ! Answer Try my code (I used the reference operator “&” to get the successive inner arrays): Input array: php code: Result array:

Iterate through a php multi dimensional array with specific condition

I have a php array below and i want to know how to get number of companies who did a training course. Look below: Each array represents the record of a worker in the database from a company say Alucam and did training Electrical safety. So from the array above i want to get something like: 2 Alucams did electrical

php: Add value to exsiting key in array

I have an array: I want to add one or more value to the “email”. What I want to achieve is: Is there a way to push it? Answer You can do this, but you should be clear that it’s what you want to do. If you change the datatype of any part of your program there could be unexpected

PHP: Explode comma outside of brackets

Below is a string I’ve tried to explode only on comma’s outside of the first set of brackets. Wheat Flour (2%) [Wheat Flour, Wheat Gluten, Calcium Carbonate, Iron, Niacin (B3), Thiamin (B1), Ascorbic Acid], Water, Yeast, Salt, Vegetable Oils (Palm, Rapeseed, oils (sunflower, rapeseed)), Soya Flour 1st Attempt Which returns: 2nd Attempt Returns: The first attempt is the closest I’ve

Detect if array contains another array

I’m using external API for my website. When user select city and town, API returns neighborhoods. But the problem is, if there is only one neighborhood array contains name and neighborhood id. But if there is more than one, it contains multiple array for each neighborhood. Single example ; Multiple Example ) I have to show data to user inside

Advertisement