title: Convert Array To Collection in Laravel
body: <p>I have the following array in PHP:</p>
  
  <pre><code>[
    {
       "website": "example",
       "url": "example.com"
    },
    {
       "website": "example",
       "url": "example.com"
    }
  ]
  </code></pre>
  
  <p>Now I would like to convert this to a collection so I sort by the keys <code>website</code> or <code>url</code>.  However when I do this:</p>
  
  <pre><code>$myArray = collect(websites);
  </code></pre>
  
  <p>I get this instead:</p>
  
  <pre><code> {
        "0": {
           "website": "example",
           "url": "example.com"
        },
        "1": {
           "website": "example",
           "url": "example.com"
        }
      }
  </code></pre>
  
  <p>And the sorting does not work, I would like to know what I am doing wrong and how I can fix it so I have an array collection of objects I can easily sort.</p>
  
  <p><strong>Edit:</strong>
  I expect the output to be the same as this:</p>
  
  <pre><code>[
    {
       "website": "example",
       "url": "example.com"
    },
    {
       "website": "example",
       "url": "example.com"
    }
  ]
  </code></pre>
  
  <p>By "sorting does not work" I meant the items are not sorted.</p>