Returning all values from foreach in function php [closed]

Try this:

function returncartdata($data) {
        $return = '';
    foreach ($data as $carthtml => $itemhtml) {
        $return .= $itemhtml[0];
        $return .= $itemhtml[1];
        $return .= $itemhtml[2];
        $return .= $itemhtml[3];
        $return .= $itemhtml[4];
    }           
        return $return;    
}
$rawhtmlcartdata = cart_items_array();
$ordercart = returncartdata($rawhtmlcartdata);

wp_insert_post(array (
           'post_type' => 'saved-orders',
           'post_title' => 'Test',
           'post_content' => $ordercart,
           'post_status' => 'publish',
           'comment_status' => 'closed',   // if you prefer
           'ping_status' => 'closed',      // if you prefer
        ));

error code: 523