I am using codeigniter. I generate a custom error message from the errors which I get from codeigniter form validation:
$this->message->set_error ( $this->form_validation->error_array () );
$message = $this->message->get_message ();
echo "<pre>"; print_r($message); die;
$this->data ['message'] = $message;
the $message is this
<div class="errormsg message">
<p>
<em>Error</em>
</p>
<ul>
<li>The First Name field is required.</li>
<li>The Last Name field is required.</li>
<li>The Date of birth field is required.</li>
<li>The Email address field is required.</li>
<li>The Password field is required.</li>
<li>The Password Confirmation field is required.</li>
<li>The City field is required.</li>
<li>The State field is required.</li>
<li>The captureCode field is required.</li>
</ul>
</div>
i have another error string
$err = 'Age is below 14';
I want to add this $err to the <ul>
so the resulting <ul> will be
<ul>
<li>The First Name field is required.</li>
<li>The Last Name field is required.</li>
<li>The Date of birth field is required.</li>
<li>The Email address field is required.</li>
<li>The Password field is required.</li>
<li>The Password Confirmation field is required.</li>
<li>The City field is required.</li>
<li>The State field is required.</li>
<li>The captureCode field is required.</li>
<li>Age is below 14</li>
</ul>
What is the best way to do this?
Instead of using something like DOMDocument to append the element, you can use a simple string replace:
Demo