1

PHP code :

print_r($InformationRetrieval['KeywordExtraction'][1]);

Outputs :

Array
(
    [google] => 15
    [search] => 18
    [or] => 2
    [web] => 4
    [is] => 4
    [a] => 5
    [engine] => 2
}

but needs to print words that are indexes of this array eg: google, search, or, web etc..

How is it done?

2
  • You can use array_keys See my answer and demo further details Commented Apr 13, 2014 at 11:21
  • Your title mentions JSON. Are you looking for json_encode() ? Commented Apr 13, 2014 at 11:27

2 Answers 2

1

You can use array_keys;

print_r(array_keys($InformationRetrieval['KeywordExtraction'][2]));

Here is a working demo: Demo

Sign up to request clarification or add additional context in comments.

Comments

0

use this :

<?php
$a = array("google" => 15, "search" => 18, "or" => 2, "web" => 4, "is" => 4, "a" => 5, "engine" => 2);

foreach($a as $key=>$value) {
   echo $key;
}
?>

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.