S
S
Soho2016-02-09 03:40:43
PHP
Soho, 2016-02-09 03:40:43

How to display numbers in data-content like 1 2 3 4?

Sorry guys, but I'm not a programmer, so I asked a question to people who understand this.
I make a list output as on this site.
So, my function is responsible for this

function h3_list($attr,$content= null){
return'<div class="custom-list" data-content=''><h3>'.$content.'</h3></div>';
}

in the visual editor, I click on the Shortcode button, and it inserts a construction around the Header
<div class="custom-list" data-content=''><h3>Заголовок</h3></div>

So you need to register a counter in the function, or I don’t know what needs to be written there so that a number is inserted into the data-content = '' property as in the list.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2016-02-09
@Stalker_RED

for ($i = 1; $i < 4; $i++ ) {
    echo "<div class=\"custom-list\" data-content=\"$i\"><h3>Заголовок $i</h3></div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor";
}

But when you are mature enough to output real data instead of "fish", it's better to use foreach

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question