function vv($var, $level = 3, &$result = null, $isView = true) { if ($var && (is_array($var) || is_object($var))) { if ($level > 0) { if (is_object($var)) { $var = vvvv($var); } foreach ($var as $key => $value) { vv($value, $level - 1, $result[$key], false); } } else { $result = '...any array or object'; } } else { $result = $var; } if ($isView) { vvv($result); } }
<div id="login"> <h1><span>Welcome to MasterDash!</span></h1> <div id="login_panel" class="form"> <form action="/home/login" method="post"> <div class="login_fields"> <div class="field"> <label for="user_email">Email</label> <?php echo form_error('data[user_email]'); ?> <?php $value = set_value('data[user_email]', vv($data, 'user_email', 1)); $field_data = array('name' => 'data[user_email]', 'size' => '30', 'maxlength' => '255', 'id' => 'user_email', 'placeholder' => '*****@*****.**', 'tabindex' => '1'); echo form_input($field_data, $value); ?> </div> <div class="field"> <label for="user_password">Password <small><a href="/home/password_reminder">Forgot Password?</a></small></label> <?php echo form_error('data[user_password]'); ?> <?php $field_data = array('name' => 'data[user_password]', 'size' => '15', 'maxlength' => '255', 'id' => 'user_password', 'placeholder' => 'password', 'tabindex' => '2'); echo form_password($field_data); ?> </div> </div> <div class="login_actions clearfix"> <button type="submit" class="btn teal primary" tabindex="3">Login</button> <a href="/home/create_account">Create Account</a> </div>
$val = "Val changed"; $ref = "Ref changed"; } function rr(&$ref1, &$ref2) { $ref1 = "Ref1 changed"; $ref2 = "Ref2 changed"; } } echo "\n ---- Pass by ref / pass by val: functions ----\n"; unset($u1, $u2); v($u1); r($u2); var_dump($u1, $u2); unset($u1, $u2); vv($u1, $u2); var_dump($u1, $u2); unset($u1, $u2); vr($u1, $u2); var_dump($u1, $u2); unset($u1, $u2); rv($u1, $u2); var_dump($u1, $u2); unset($u1, $u2); rr($u1, $u2); var_dump($u1, $u2); echo "\n\n ---- Pass by ref / pass by val: static method calls ----\n"; unset($u1, $u2); C::v($u1); C::r($u2); var_dump($u1, $u2);
<?php echo form_error('data[user_email]'); ?> <?php $value = set_value('data[user_email]', vv($data, 'user_email', 1)); $field_data = array('name' => 'data[user_email]', 'size' => '30', 'maxlength' => '255', 'id' => 'user_email', 'placeholder' => '*****@*****.**', 'tabindex' => '1'); echo form_input($field_data, $value); ?> </div> <div class="field"> <label for="client_name">Organisation</label> <?php echo form_error('data[client_name]'); ?> <?php $value = set_value('data[client_name]', vv($data, 'client_name', 1)); $field_data = array('name' => 'data[client_name]', 'size' => '30', 'maxlength' => '255', 'id' => 'client_name', 'placeholder' => 'My Company', 'tabindex' => '2'); echo form_input($field_data); ?> </div> <p> Enter your email and organisation name above, hit Create Account, and we'll email you a password so you can access MasterDash. </p> </div> <div class="login_actions clearfix"> <button type="submit" class="btn teal primary" tabindex="3">Create Account</button> <a href="/">Login</a> </div> </form> </div> </div>