NotionCommotion Posted September 25, 2016 Share Posted September 25, 2016 (edited) $response->withJson() accepts an array which will be transformed to JSON as well as an optional integer which specifies the HTTP status code (if not given, uses 200).Alternatively, I can use $response->withStatus($desiredCode); to set the HTTP status code.Is there a more concise way to perform the following? $rs=myFunction(); return $response->withJson($rs['array'],$rs['code']); // or return $response->withJson($rs['array'])->withStatus($rs['code']); PS. This relates to the Slim framework, and I don't wish to modify the script related to $response. Edit. Other than use using something like $rs[0] and $rs[1]. Edited September 25, 2016 by NotionCommotion Quote Link to comment https://forums.phpfreaks.com/topic/302239-setting-two-arguements-with-single-function/ Share on other sites More sharing options...
requinix Posted September 25, 2016 Share Posted September 25, 2016 Nothing that would be better. Quote Link to comment https://forums.phpfreaks.com/topic/302239-setting-two-arguements-with-single-function/#findComment-1537809 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.