title: How to i compare and fill a json array with another json array in Laravel
body: <p>I am using Laravel 9 and building a REST API service
  User will send me json data which is getting saved in mySQL database and that very same time the data is formatted and sent to an external API endpoint so that the data gets synced in the whole workflow.</p>
  <p>The reason for building a new REST API service is because the earlier API that was built is very complicated for the user to understand, specifically the request body that needs to be sent.</p>
  <p>This is how the user will send me the JSON data. Lets call this as &quot;ShortJSON&quot;</p>
  <pre><code>&quot;restrictions&quot;: {
              &quot;crown_top_left&quot;: [
                  1,
                  3,
                  5
              ],
              &quot;crown_top_right&quot;: [
                  2,
                  5,
                  7
              ]
  }
  </code></pre>
  <p>So the &quot;crown_top_left&quot; or other object will have any combination of numbers &quot;2,4,8&quot; and so on.</p>
  <p>Now the issue is, the external API that i am posting the data, accepts the data in this format. Lets call this as &quot;LongJSON&quot;</p>
  <pre><code>&quot;crown_Tooths_obj&quot;: {
              &quot;crown_upper_left_1&quot;: true,
              &quot;crown_upper_left_2&quot;: false,
              &quot;crown_upper_left_3&quot;: true,
              &quot;crown_upper_left_4&quot;: false,
              &quot;crown_upper_left_5&quot;: true,
              &quot;crown_upper_left_6&quot;: false,
              &quot;crown_upper_left_7&quot;: false,
              &quot;crown_upper_left_8&quot;: false,
              &quot;crown_lower_left_1&quot;: false,
              &quot;crown_lower_left_2&quot;: false,
              &quot;crown_lower_left_3&quot;: false,
              &quot;crown_lower_left_4&quot;: false,
              &quot;crown_lower_left_5&quot;: false,
              &quot;crown_lower_left_6&quot;: false,
              &quot;crown_lower_left_7&quot;: false,
              &quot;crown_lower_left_8&quot;: false,
  } 
  </code></pre>
  <p>I want a way to map the ShortJSON to the LongJSON, in such a way that the LongJSON values becomes true or false according to the numbers present in the ShortJSON</p>
  <p>E.g. if &quot;crown_top_left&quot; in ShortJSON has [1,2,3]
  then the output of the LongJSON should be</p>
  <pre><code>&quot;crown_Tooths_obj&quot;: {
                  &quot;crown_upper_left_1&quot;: true,
                  &quot;crown_upper_left_2&quot;: true,
                  &quot;crown_upper_left_3&quot;: true,
                  &quot;crown_upper_left_4&quot;: false,
                  &quot;crown_upper_left_5&quot;: false,
                  &quot;crown_upper_left_6&quot;: false,
      }
  </code></pre>
  <p>1,2 &amp; 3 are present so the values will become true</p>
  <p>I tried array_map, array_diff and many things but they are altogether something else. They are not helping me to what i am trying to do. I have wasted one night. Please help me out</p>
  <p>I hope i have asked out the question in the most clearest manner possible</p>