• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP Array

Here's some code to get you going:
PHP:
<?php

function array_count_duplicate_values($array)
{
	foreach($array as $value)
	{
		$return[$value] = (isset($return[$value])) ? $return[$value]++ : 1;
	}
	return $return;
}

?>

You should be able to get the rest of what you want quite easily (Hey, I'm not doing it all for you, but if you have any more problems, feel free to ask).
 
PHP:
<?
//Set the array as a varible.
$array=array("harry", "mary", "john", "harry", "harry");
//Change the array to a string.
$string=implode("\n",$array);
echo $string;
?>
This will produce;
harry
mary
john
harry
harry

PHP:
<?
//Set the array as a varible.
$array=array("harry", "mary", "john", "harry", "harry");
//Count values in the array.
$array1=array_count_values($array);
//set the template to show.
echo "Harry : ".$array1['harry']."<br> Mary : ".$array1['mary']."<br> John : ".$array1['john'];
?>

This outputs,
Harry : 3
Mary : 1
John : 1
 
Last edited:
Back
Top