0

value of $attributes['st_title'] is <a href="/physical-design-engineers">Physical Design Engineers</a>

I want to remove <a href="/physical-design-engineers"> and </a>. The final expected output is: $attributes['st_title'] = Physical Design Engineers

I am trying as follows:

    $pattern[0] = "/<a.[^>]+>/";
    $pattern[1] = '/</a>/';

    $replacement[1] = '';
    $replacement[0] = '';
    $attributes['st_title'] = preg_replace( $pattern, $replacement, $attributes['st_title'] );

But it sets $attributes['st_title'] as empty. Any idea?

Abdus Sattar Bhuiyan
  • 3,016
  • 4
  • 38
  • 72

2 Answers2

4

Since you want text only from the link, so use strip_tags()

echo strip_tags($text); 

https://eval.in/979039

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
2

Use php strip_tags()

or

preg_replace("/<.*?>/", "", $attributes['st_title']);
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Rp9
  • 1,955
  • 2
  • 23
  • 31