user186730 user186730 - 22 days ago 9
PHP Question

How can I remove substring from an array and we are fetch data from the database?

I want to remove only development and want to fetch rest of the array?

Menus is table having one column with below names:


  • web Development

  • App Development

  • Digital stratergy

  • graphic Team



I need this should be come in below fromat
web, graphic team, app, Digital stratergy

I am able to get in same order but unable to remove development.. I tried below code.
Thanks for help in advance.

foreach($requiredOrderForService as $index){
echo urldecode(strtoupper($this->Html->link($serv[$index]['Service']['name'],array('controller' => $serv[$index]['Service']['controller'],
'action' => $serv[$index]['Service']['action'],$serv[$index]['Service']['id'],
'admin' => false,
'plugin' => false),array('class'=>'menuForFooter2'))));
echo "<br>";

}

Answer Source

I am not familiar with cakephp but based on the response to my comment you can do something like this,

foreach($requiredOrderForService as $index){
   echo  urldecode(strtoupper($this->Html->link(str_replace('Development','',$serv[$index]['Service']['name']),array('controller' => $serv[$index]['Service']['controller'],
           'action' => $serv[$index]['Service']['action'],$serv[$index]['Service']['id'],
           'admin' => false,
           'plugin' => false),array('class'=>'menuForFooter2'))));
   echo "<br>";

}