{"id":743,"date":"2017-02-24T19:49:53","date_gmt":"2017-02-25T03:49:53","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=743"},"modified":"2017-02-24T19:49:53","modified_gmt":"2017-02-25T03:49:53","slug":"php-reading-from-command-line","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=743","title":{"rendered":"PHP Reading from command line"},"content":{"rendered":"<pre>\n$handle = fopen (\"php:\/\/stdin\",\"r\");<br \/>\n\/\/ if single input (having no spaces)<br \/>\nfscanf($handle,\"%d\",$n);<br \/>\n\/\/ if trying to read 2 values separated by a space<br \/>\nfscanf($handle,\"%d %s\",$d,$s);<br \/>\n\/\/ if trying to read a string having spaces<br \/>\n$inp = trim(fgets($handle));<\/p>\n","protected":false},"excerpt":{"rendered":"<p>$handle = fopen (&#8220;php:\/\/stdin&#8221;,&#8221;r&#8221;); \/\/ if single input (having no spaces) fscanf($handle,&#8221;%d&#8221;,$n); \/\/ if trying to read 2 values separated by a space fscanf($handle,&#8221;%d %s&#8221;,$d,$s); \/\/ if trying to read a string having spaces $inp = trim(fgets($handle));<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=743"}],"version-history":[{"count":1,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":744,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions\/744"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}