Author Archives: Roopendra - Page 13

PHP

Count matching occurrences in php array

You can Count matching occurrences in php array using php array function array_count_values() Syntax: array array_count_values ( array $array ) array_count_values() returns an array using the values of array as keys and their frequency in array as values.  Example:-   <?php       $array = array(1,"roopendra",1,"php","roopendra");       print_r(array_count_values($array));   ?> Above code will…
Continue Reading
PHP

Validate URL in PHP

You can validate URL in PHP using regular expression or using validate filters Validate URL in PHP using regular expression: Example:- <?php // Write you regular expression pattern to match URL $pattern = @#\/%=~_|]/i"; // Assign URL to $URL variable $URL = ';name=roop'; // Check url using preg_match if (…
Continue Reading
PHP

Post JSON data via PHP cURL

Post JSON data via PHP cURL We can Post JSON data via PHP curl by using header Content-Type: application/json in CURLOPT_HTTPHEADER. Below is working code demonstration of PHP curl with post json field. <?php $url = ''; $jsonString = json_encode(array("key" => "value")); // You can directly replace your JSON string with…
Continue Reading
Verified by MonsterInsights