<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users923</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/923" rel="self"/>
  <title>Just Another Programmer</title>
  <updated>Fri Dec 19 05:10:52 -0800 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor129176</id>
    <published>2008-12-19T05:10:52-08:00</published>
    <title>[PHP] On Random password</title>
    <content type="html">&lt;p&gt;This one uses special characters also, and shuffles it all around etc..&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php
function randomPassword($length) {
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!@#$%^&amp;amp;*(){}[]|~';
    $charsarray = array();
    for ($n=0; $n &amp;lt; rand(0,rand(0,100)); $n++) {
        $charsarray[] = str_shuffle($chars);
    }
    $password = substr(str_shuffle(str_shuffle(implode($charsarray))),rand(0,strlen($password))-$length,$length);
    return $password;
}
echo randomPassword(12);
//Sample generated password: tY$%bSzzU!e[
?&amp;gt;&lt;/pre&gt;</content>
    <author>
      <name>Just Another Programmer</name>
      <email>corey1981@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/90-random-password/refactors/129176" rel="alternate"/>
  </entry>
</feed>

