-1

I am novice in php development and I need your help.

I have read the column of a file and I want to keep in an array only the distinct values

I do it with this code in a while (fgetcsv) loop

$sex_array = array();
isset($sex_array[$sex])?$sex_array[$sex]++:$sex_array[$sex]=1;

my array is in format Array ( [man] => 33 [woman] => 141 )

How can I make a variable and when I print it to take man:33,woman:141

I tried implode but I take 33,141

1 Answer 1

0

look at foreach taken from the page:

foreach ($a as $k => $v) {
    echo "\$a[$k] => $v.\n";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.