matt0268 Posted October 4, 2013 Share Posted October 4, 2013 Doing some bitmasking, how do i store this in a variable/temp variable? $val = 128; $places = $_GET['action']; $res = $val >> $places; p($res, $val, '>>', $places); function p($res, $val, $places, $note = '') { $format = '%0' . (PHP_INT_SIZE * 1) . "b\n"; printf($format, $res); } Link to comment https://forums.phpfreaks.com/topic/282700-storing-this-in-a-variable/ Share on other sites More sharing options...
Barand Posted October 4, 2013 Share Posted October 4, 2013 Change your function to return the value instead of echo $val = 128; $places = $_GET['action']; $res = $val >> $places; $stored = p($res, $val, '>>', $places); function p($res, $val, $places, $note = '') { $format = '%0' . (PHP_INT_SIZE * 1) . "b\n"; return sprintf($format, $res); } Link to comment https://forums.phpfreaks.com/topic/282700-storing-this-in-a-variable/#findComment-1452524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.