how to get inner array from Outer array

nested arrays javascript
javascript push array into array multidimensional
javascript array
javascript multidimensional array push
get value from array javascript
array of arrays javascript
javascript 3d array
javascript multidimensional array push with keys

I want to pull a array from outer array.

My result

I want to remove circle symbol of array

{
"Success": "1",
"Message": "Subtopic Wise Questions...",
"Subtopic Questions": [
    [
        {
            "id": "93",
            "topic_id": "36",
            "name": "Cell membrane and organelle",
            "created_at": "2018-08-29 23:06:34",
            "updated_at": "2018-08-29 23:06:34",
            "q_count": "127"
        }
    ],   
]

}

Here is my output result of array. the

My Controller code

 foreach($findid as $v)
        {
            $count[] = DB::table('questions')
                        ->join('subtopics', 'subtopics.id', 'questions.subtopic_id')
                        ->select('subtopics.*', DB::raw('count(questions.id) as q_count'))
                        ->where('subtopic_id', $v)
                        ->get();
        }


        return response([
                    'Success' => "1",
                    'Message' => "Subtopic Wise Questions...",
                    'Subtopic Questions'   => $count
                    ]); 

use first() to obtain just an object as per your image you want to remove extra array quotes so

$count[] = DB::table('questions')
                    ->join('subtopics', 'subtopics.id', 'questions.subtopic_id')
                    ->select('subtopics.*', DB::raw('count(questions.id) as q_count'))
                    ->where('subtopic_id', $v)
                    ->first();

Hope it helps you!

Learn JavaScript Multidimensional Array By Examples, This tutorial shows you how to create a JavaScript multidimensional array by loop the outer array for (let i = 0; i < activities.length; i++) { // get the size of the  a nine-run inner array (design of resolution 3) is chosen for the control factors. The POINTREP option in the OUTPUT statement replicates the eight-run outer array in the data set OUTERARY for each of the nine runs in the inner array and saves the

use whereIn method instead of where method

note only store id in array then used whereIn method

$count = DB::table('questions')
                ->join('subtopics', 'subtopics.id', 'questions.subtopic_id')
                ->select('subtopics.*', DB::raw('count(questions.id) as q_count'))
                ->whereIn('subtopic_id', array_wrap($findid))
                ->get();

note if not working as u want restult then add toArray() method in query like this

$count->toArray();

 return response([
               'Success' => "1",
               'Message' => "Subtopic Wise Questions...",
               'Subtopic Questions'   => $count
     ]);

Nested Arrays in JavaScript, So far, all the arrays we've dealt with have been “flat” arrays; each array element contains a single value, such as a number, string, or object. If you want to use inner classes from inside main()or from outside the outer class you have to use an instance of outer in order to access them, same like accessing any other instance member - you can't access it directly: Outerclass oc = new Outerclass(); Outerclass.InnerClass in = oc.new InnerClass();

Your query is expensive. Since you are looping through array of ids, you are going to run queries count(findid) number of times. You can optimize and achieve the same as,

$count = DB::table('questions')
            ->join('subtopics', 'subtopics.id', 'questions.subtopic_id')
            ->select('subtopics.*', DB::raw('count(questions.id) as q_count'))
            ->whereIn('subtopic_id', $findid)
            ->get();


return response([
    'Success' => "1",
    'Message' => "Subtopic Wise Questions...",
    'Subtopic Questions'   => $count
]); 

Introduction to Optimum Design, In the outer array, we calculate μf and σf for each row of the inner array as shown in Table 20.23. To use the loss function in Eq. (20.59), we need a target; the  Why is creating an array in a outer parameterized class with a component type being an inner class considered "Generic array creation"? January 2019 JavaScript: Calling Array.reduce when outer function is called, and outer function has arguments

JavaScript Multidimensional Arrays, JavaScript multidimensional arrays defined and demonstrated. How to access The first square bracket references the desired element in the outer array. The second square Find out more about methods to add and remove array elements. Control factors are put in the 'inner array' and noise factors in the outer array. An example is shown below. The experiment is to find the best values for the three design features in a relief valve: Hole Size, Spring Length and Ball Size.

8.2.1. Nested Loops for 2D Arrays, The length of the outer array is the number of rows and the length of one of the find out the number of rows and columns in a 2D array you can use a nested for  The inner array is essentially any experiment design that is used to study the effect of the control factors on the response. Taguchi then used an outer array for the noise factors so that each run of the inner array was repeated for every treatment of the outer array. The resulting experiment design, that uses both inner and outer arrays, is

Array Functions - Manual, Here is a function to find out the maximum depth of a multidimensional array. <?​php // return depth of given array // if Array is a string ArrayDepth() will return 0 PHP how get inner arrays from multidimensional arrays without using any for and foreach loops . Posted by: admin October 27, 2017 Leave a comment

Comments
  • use $count instead of $count[]
  • make foreach loop through Subtopic Questions->Subtopic Questions
  • @JigneshJoisar if i use $count it's return only first column of result.
  • Seems to my you should try to fetch all required rows at once instead of one each time.
  • @KrishBhardwaj Eloquent will return an array of objects as you have displayed result it is clearly shown that its an array of objects if you dont use toArray() . So if you just want to pull array not object than you will need to use toArray()
  • i used toArray() but not working to achieve result according me.
  • ohh okay i got it ! please check my edited answer. @KrishBhardwaj
  • @KrishBhardwaj QueryBuilder will return Illuminate\Support\Collection. @LeenaPatel Eloquent will return `Illuminate\Database\Eloquent\Collection. Not array or array of objects.
  • Can replace is_array($findid) ? $findid : [ $findid] with array_wrap($findid)