0

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?

10
  • Hey there. You can't treat an array as a function. Commented May 13, 2021 at 10:39
  • @Jwan I asked for another method no one helps, they only focused on downvote Commented May 13, 2021 at 11:36
  • If you can be more clear. I might be able to help you. Just post the hole code and I can help :). Commented May 13, 2021 at 11:52
  • 1
    Are the numbers in array? Commented May 13, 2021 at 13:44
  • 1
    Then use str_replace $numbers array with $status array Commented May 13, 2021 at 13:59

1 Answer 1

1

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;

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

2 Comments

What you are showing and asking here is incomplete, faulty and not reproducible.
could you please elaborate @jspit have you check the question? I also asked for how will I modify to get the desire results

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.