About 223,000 results
Open links in new tab
  1. Best way to initialize (empty) array in PHP - Stack Overflow

    There's no such thing as "initializing" an array's index-keys with dummy/placeholder values. print_r gives: Array ( [IdxKeyOne] => [IdxKeyTwo] => [IdxKeyThr] => ) where the elements exist, having defined keys but null-values. When using the array later, you would have to drop the dummy-row anyway.

  2. Create an array inside array in PHP - Stack Overflow

    Mar 3, 2017 · PHP - create a JSON object with multiple arrays Hot Network Questions A family has a child.They adopt a girl as well.If one of the children becomes #1 in a women's race, what is the probability of the girl being adopted?

  3. How to create an array for JSON using PHP? - Stack Overflow

    Nov 29, 2016 · Read my post again. If you want something to translate into a JSON object, make it an associative array in PHP (where the keys are strings). If you want it to translate into a JSON list, make it a plain array (with implicit integer keys). The value of each array element can in turn be an array, which is what you want. –

  4. php - Add data dynamically to an Array - Stack Overflow

    Aug 14, 2020 · Let's say you have defined an empty array: $myArr = array(); If you want to simply add an element, e.g., 'New Element to Array', write

  5. php - How do I declare a two dimensional array? - Stack Overflow

    Nov 28, 2009 · What's the easiest way to create a 2d array. I was hoping to be able to do something similar to this: declare int d[0..m, 0..n]

  6. php - How can I create an array from the values of another array's …

    both array_map and foreach() are O(n), but the array_map call has to build the function and call it for reach item in the array, in addition to doing the actual iteration. The foreach() loop doesn't have the function overhead, so it's faster. array_map should only really be used if you're doing something complicated with each item in the array.

  7. php - Is it possible to declare an array of objects? - Stack Overflow

    How to create an array with objects in php. 0. Php doing a for loop with OOP,can't figure out how. 0.

  8. In PHP, how can I add an object element to an array?

    Jan 28, 2013 · @Erk: the method private function TestClass does the same thing, it's the old way in PHP of setting up a constructor (from PHP 4). From PHP 5, your way is preferred. From PHP 5, your way is preferred.

  9. php - Split a comma-delimited string into an array? - Stack Overflow

    I need to split my string input into an array at the commas. Is there a way to explode a comma-separated string into a flat, indexed array? Input: 9,[email protected],8 Output: ['9', 'admin@exampl...

  10. Creating new array from existing arrays in php - Stack Overflow

    PHP merging two arrays to create a new array. 0. PHP: Merge specified sub-arrays into new array? Hot ...

Refresh