title: How to encode two arrays using json_encode?
body: <p>I am using <code>json_encode</code> to get the JSON data but along with it I want to pass message if data is successfully passed or not that in the JSON. I am confused how to get the solution. I need only one response not two.</p>
  
  <pre><code>&lt;?php
  $url = isset($_REQUEST["url"]) ? $_REQUEST["url"] : '';
  require_once dirname(__FILE__) . '/bootstrap.php';
  $recipe = RecipeParser::parse(file_get_contents($url), $url);
  
  //echo '&lt;pre&gt;';
  //print_r($recipe);
  //echo '&lt;/pre&gt;';
  if($recipe) {
              $Return['status'] = 'true';
              $Return['message'] = " Data found";
      } else {
              $Return['status'] = 'false';
              $Return['message'] = "Data not found";
      }
  
  header('Content-type: application/json');
  echo json_encode($recipe);
  echo json_encode($return);
  ?&gt;
  </code></pre>
  
  <p>Output of first array:</p>
  
  <pre><code>{"title":"Keto Pizza \u2013 The Best Pizza Recipe with Video \u2013 Diet Doctor","description":"","credits":"Anne Aobadia","notes":"","yield":"2 servings","source":null,"url":"https:\/\/www.dietdoctor.com\/recipes\/keto-pizza","categories":[],"photo_url":"https:\/\/i.dietdoctor.com\/wp-content\/uploads\/2016\/01\/keto_pizza_v.jpg?auto=compress%2Cformat&amp;w=1600&amp;h=1067&amp;fit=crop","_parser":"StructuredData","time":{"prep":5,"cook":25,"total":30},"ingredients":[{"name":"","list":["4 eggs","11 oz. shredded cheese, preferably mozzarella or provolone","3 tbsp unsweetened tomato sauce","1 tsp dried oregano","1 1\/2 oz. pepperoni","olives (optional)","2 oz. leafy greens","4 tbsp olive oil","sea salt","ground black pepper"]}],"instructions":[{"name":"","list":["Preheat the oven to 400\u00b0F (200\u00b0C).","Start by making the crust. Crack eggs into a medium-sized bowl and add shredded cheese. Give it a good stir to combine.","Use a spatula to spread the cheese and egg batter on a baking sheet lined with parchment paper. You can form two round circles or just make one large rectangular pizza. Bake in the oven for 15 minutes until the pizza crust turns golden. Remove and let cool for a minute or two.","Increase the oven temperature to 450\u00b0F (225\u00b0C).","Spread tomato sauce on the crust and sprinkle oregano on top. Top with cheese and place the pepperoni and olives on top.","Bake for another 5-10 minutes or until the pizza has turned a golden brown color.","Serve with a fresh salad on the side."]}]}
  </code></pre>
  
  <p>Output of second array:</p>
  
  <pre><code> {"status":"true","message":" Data found"}
  </code></pre>
  
  <p>Array output:</p>
  
  <pre><code>RecipeParser_Recipe Object
     (
     [title] =&gt; Keto Pizza – The Best Pizza Recipe with Video – Diet Doctor
     [description] =&gt; 
     [credits] =&gt; Anne Aobadia
     [notes] =&gt; 
     [yield] =&gt; 2 servings
     [source] =&gt; 
     [url] =&gt; https://www.dietdoctor.com/recipes/keto-pizza
     [categories] =&gt; Array
        (
        )
  
      [photo_url] =&gt; https://i.dietdoctor.com/wp-content/uploads/2016/01/keto_pizza_v.jpg?auto=compress%2Cformat&amp;w=1600&amp;h=1067&amp;fit=crop
      [_parser] =&gt; StructuredData
      [time] =&gt; Array
      (
          [prep] =&gt; 5
          [cook] =&gt; 25
          [total] =&gt; 30
      )
      [ingredients] =&gt; Array
      (
          [0] =&gt; Array
              (
                  [name] =&gt; 
                  [list] =&gt; Array
                      (
                          [0] =&gt; 4 eggs
                          [1] =&gt; 11 oz. shredded cheese, preferably mozzarella or provolone
                          [2] =&gt; 3 tbsp unsweetened tomato sauce
                          [3] =&gt; 1 tsp dried oregano
                          [4] =&gt; 1 1/2 oz. pepperoni
                          [5] =&gt; olives (optional)
                          [6] =&gt; 2 oz. leafy greens
                          [7] =&gt; 4 tbsp olive oil
                          [8] =&gt; sea salt
                          [9] =&gt; ground black pepper
                      )
                 )
              )
          [instructions] =&gt; Array
          (
          [0] =&gt; Array
              (
                  [name] =&gt; 
                  [list] =&gt; Array
                      (
                          [0] =&gt; Preheat the oven to 400°F (200°C).
                          [1] =&gt; Start by making the crust. Crack eggs into a medium-sized bowl and add shredded cheese. Give it a good stir to combine.
                          [2] =&gt; Use a spatula to spread the cheese and egg batter on a baking sheet lined with parchment paper. You can form two round circles or just make one large rectangular pizza. Bake in the oven for 15 minutes until the pizza crust turns golden. Remove and let cool for a minute or two.
                          [3] =&gt; Increase the oven temperature to 450°F (225°C).
                          [4] =&gt; Spread tomato sauce on the crust and sprinkle oregano on top. Top with cheese and place the pepperoni and olives on top.
                          [5] =&gt; Bake for another 5-10 minutes or until the pizza has turned a golden brown color.
                          [6] =&gt; Serve with a fresh salad on the side.
                      )
                  )
               )
             )
  </code></pre>