4

I am trying to reproduce the following markup with php-class-html-generator, but I am stuck with inserting <i> and setting text at the end, just before </h4>

Original HTML

<h4 class="formTitle lead">
    <span class="widget-number"><i class="icon-comments"></i></span>Random
</h4>

My Code:

$h4 = HTMLTag::createElement('h4')->setText("Random")
    ->addClass('formTitle')
    ->addClass('lead');
$h4->addElement('span')
    ->addClass('widget-number');
return($h4);

My output at the moment:

<h4 class="formTitle lead">
     <span class="widget-number">Random</span>
</h4>


Thanks for your help!

4
  • You question is not clear. What exactly do you want? Commented Mar 23, 2013 at 3:08
  • I want to reproduce original html with php-class-html-generator :) Commented Mar 23, 2013 at 3:10
  • 1
    I'd like to help, if I knew how to use it. Looks like a good script. Commented Mar 23, 2013 at 3:11
  • 1
    Getting the hang of it. Cool script, upvoting all for this great find, cheers! Commented Mar 23, 2013 at 3:43

1 Answer 1

3

Try this-

$h4 = HTMLTag::createElement('h4')->setText("Random")->addClass('formTitle')->addClass('lead');

$span = $h4->addElement('span')->addClass('widget-number');

$i = $span->addElement('i')->setText(' ')->addClass('icon-comments');

Result -

    <h4 class="formTitle lead">
<span class="widget-number">
<i class="icon-comments"></i></span>Random</h4>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.