Get Text From

前端 未结 5 1868
野趣味
野趣味 2020-11-29 08:32

I want to get text inside the tags as well as its value.

Example


  
  
  

PHP

$value = split(':', $make)[0];
$text = split(':', $make)[1];

Benefits of this method
Yes, there are definitely similarities to serialworm's answer, yet we minimize the code in our PHP block by inconspicuously converting to an array and picking the element required right away.

In my case, I use this exact short-hand code in a contact form where this one-liner (to get the selected department name) is critical to keeping the code looking clean.

提交回复
热议问题