Log in

View Full Version : Adding a dot in between to my table of content list style



FelixArthur
04-30-2020, 10:40 AM
I'm banging my head to the wall since I can't seem to find how to do a simple thing. I have a list of content made with a WP plugin called Table of content plus. It only lets you do two option: show the number list or hide it. I want to show it, but I want to add a simple "." before the number.

For example, in the first one I want it to be shown like this: "1. Resumen 'too long; didn't read'" instead of "1 Resumen 'too long; didn't read". Just a simple "." before the number, but I'm not able to figure it out! I tried all the css property list-style with no results.

Any help will be much appreciated.

Thank you!

james438
05-01-2020, 12:29 AM
I could probably create a short php script that will do what you want, but I need to take care of a few things first. I'll try to have it for you by tomorrow at the latest.

james438
05-01-2020, 03:16 AM
I'm sure this can be improved upon, but try this:


<?php
$arr="1 this is list item 1.
2 this is list item 2
3this is list item 3";
$arr=explode("\r\n",$arr);

foreach ($arr as &$value)
{
$value = preg_replace('/(^\d{0,3})/',"$1.",$value);
}
$arr=implode("<br>",$arr);
echo"$arr";
?>

If I can see the text that needs to be formatted, it will help me to understand what you are working with and how the above code needs to be modified.