KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Get 'text' of data #157

Open dimasmaliq opened this topic on on Nov 28, 2017 - 1 comments

dimasmaliq commented on Nov 28, 2017
    "name"=>"customer",
    "data"=>array(
        "John Doe"=>"1",
        "Jane Doe"=>"2",
        "Whatever Doe"=>"3",
    )  

If we want to get 'value' of data, we can do: $this->params["customer"]

But, what can i do if i want to get 'text' of data e.g. "John Doe", "Jane Doe", etc?

KoolReport commented on Nov 29, 2017

It is simple

Let say you have the $data like this

$data=>array(
        "John Doe"=>"1",
        "Jane Doe"=>"2",
        "Whatever Doe"=>"3",
    );

You have value and want to get the text, you use the array_flip()

$flip_data = array_flip($data);
$text = $flip_data[$this->params["customer"]]

Hope that helps.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

Inputs