title: Adding filter parameter to stream filter when using php://filter
body: <p>I have a binary that I want to convert to standard MIME-compliant base64 string. I thought I could use the <a href="http://www.php.net/manual/en/wrappers.php.php" rel="nofollow noreferrer"><code>php://filter</code></a> method to filter the stream, but I'm getting hung up on how to set the &quot;line-length&quot; parameter. There are other methods that would achieve similar results, but I'm trying to figure out if:</p>
  <ol>
  <li><p>If it's even possible/allowed to set parameters for stream filters using the URI-style method.</p>
  </li>
  <li><p>How it is done, if it is possible.</p>
  </li>
  </ol>
  <p>Here are the pieces to the puzzle I've got so far:</p>
  <p>Obviously, I could stop trying to be fancy and simply go with:</p>
  <pre><code>$binary = &quot;path/to/binary.file&quot;;
  $mime = file_get_contents($binary);
  $mime = base64_encode($mime);
  $mime = chunk_split($mime);
  </code></pre>
  <p>Or, I can use the <code>php://filter</code> method without the <code>line-length</code> parameter and split it afterward:</p>
  <pre><code>$binary = &quot;path/to/binary.file&quot;;
  $mime = file_get_contents(&quot;php://filter/read=convert.base64-encode/resource=$binary&quot;);
  $mime = chunk_split($mime);
  </code></pre>
  <p>Or, I can use <code>fopen</code> combined with <code>stream_filter_append</code> and not use the URL-style at all (as documented in the <a href="http://www.php.net/manual/en/filters.convert.php" rel="nofollow noreferrer">Conversion Filters</a> manual):</p>
  <pre><code>$binary = &quot;path/to/binary.file&quot;;
  $param = array('line-length' =&gt; 76, 'line-break-chars' =&gt; &quot;\r\n&quot;);
  $fp = fopen($binary, 'r');
  stream_filter_append($fp, 'convert.base64-encode',null, $param);
  $mime = fread($fp, filesize($binary));
  fclose($fp);
  </code></pre>
  <p>So all of the above give the same result, but none of them are what I was hoping for, which was to add the <code>line-length</code> parameter in the same URL for the stream. Something maybe like:</p>
  <pre><code>$mime = file_get_contents(&quot;php://filter/read=convert.base64-encode:line-length=76/resource=$binary&quot;);
  </code></pre>
  <p>I imagine the issue is that the parameter has to be passed as an array when <code>stream_filter_append</code> is used.</p>
  <p>So does anyone know if what I want can be done?</p>