PHP Tips

How to get total comments count for a post?

2018-03-14T05:36:40+00:00 By |Javascript, PHP Tips, WordPress|

Wordpress provide with the following function: <?php wp_count_comments( ); ?> The above code gets the total count of all comments present on the site. If we need to get the total comments count of a particular post then we can use following code: <?php $comments_count = wp_count_comments( $post_ID ); echo "Comments in [...]

How to explode line breaks in PHP?

2017-07-13T13:52:56+00:00 By |PHP Tips|

The following code splits a given string by line-breaks and converts it into an array: $string_array = explode(PHP_EOL, $string); The function works properly when working on the server side. But, when we pass the string via AJAX to the serve the problem occurs: line breaks are not recognized properly. To overcome this problem instead [...]