Utsav Upadhyay
Utsav Upadhyay

Reputation: 475

PHP: Function name must be a string?

I am trying to use a function that I made to convert numbers into some words but the function give me an error whenever I am trying to use it in iteration.

$status = array('freie Plätze','ausgebucht','nicht mehr buchbar','Restplätze','auf Anfrage','entfällt');

I have numbers (0,1,2,3,4,5,6) which I am using function $status to convert

it working properly in this form -

$status[$zeile->status];

but when I tried to use in while loop iteration it gives an error -

$status($zeile->($i)status);

How will I modify this function to use it in the While loop or any iteration?

Upvotes: 0

Views: 111

Answers (1)

Utsav Upadhyay
Utsav Upadhyay

Reputation: 475

I resolved my issue after trying some methods and suggested by @kevingales in the comment by str_replace() it saved my day, Thank you all.

<?php

$phrase  =  ($zeile->($i)status);
$healthy = [0,1,2,3,4,5 ];
$yummy   = ['freie&nbsp;Plätze','ausgebucht','nicht mehr buchbar','Restplätze','auf Anfrage','entfällt'];

$newPhrase = str_replace($healthy, $yummy, $phrase);

echo $newPhrase;

?>

Upvotes: 1

Related Questions