I am working with CodeIgniter and have created a custom form preferences custom config. In that I have an array that is as follows:
Array
(
[1] => Category 1
[2] => Category 2
[3] => Category 3
[4] => Category 4
[5] => Category 5
)
I am passing that to the view as the var $service_categories
what I'd then like to do is match it to the "value" that is in the database. I.E 5. If it matches then show Category 5
in the view. At the moment I am just showing 5
- This is no good to the user.
The variable $service->service_category
is a number.
The var service
produces:
Array
(
[0] => stdClass Object
(
[service_id] => 3
[organisation_id] => 2
[service_name] => Edited Service 3
[service_description] => This is service 3 provided by
[service_category] => 5
[service_metadata] => Metadata for service 3 - Edited
[service_cost] => 22.00
[service_active] => active
)
)
My current PHP for this is as follows:
if (in_array($service->service_category, $service_categories))
{
echo "Exists";
}
However, the Exists
is not showing in the view. It is showing nothing at all.
Am I doing something wrong with the in_array
method?
var_dump($service)
here ? – Marek Sebera Jul 12 '12 at 11:06