【发布时间】:2016-09-28 17:48:44
【问题描述】:
我从第 3 方 API 接收数据。
有时数据不是很好,并且有很多空白。
我试过使用 ltrim() 和 preg_replace() 没有任何运气:
$job['description'] = ltrim($job['description']);
$job['description'] = preg_replace('/^\s+/S', " ", $job['description']);
“空白”始终位于字符串的开头。以下是直接从响应中复制的:
Cover Supervisors
如果这有帮助的话。有什么想法可以尝试吗?
编辑::
var_dump 显示:
string(1664) "Cover Supervisors
Leicester & Surrounding areas
£65 - £110 per day
Required for the New Term
Immediate Interviews
Clarence Recruitment is currently looking for Cover Supervisors to work in Secondary schools across the Leicester area.
• Do you have any experience of working with children 11-16yrs and have a good knowledge of the National Curriculum?
• Are you looking to have a future within the education sector?
• Would you like the freedom to choose the days you work?
We are currently experiencing a high demand for flexible, part time and full time secondary cover supervisors.
We are therefore looking to recruit temporary staff, ideally those who are looking to build a long term career in teaching and would like to gain further school based experience before starting a PGCE/SCITT or SD program.
We are currently working with numerous vacancies so if this position is not quite for you please do send us your CV to discuss other opportunities more suitable to your requirements.
Alan (your consultant) has been working the East Midlands Desk for over 5 years so his knowledge of the local schools is exceptional. He has also gained QTS so he knows the education system extremely well. Feel free to contact him for a more detailed chat about the roles we can help you fill.
Clarence Recruitment is committed to safeguarding and promoting the welfare of children and young people and expects all staff and volunteers to share this commitment. The successful candidate will be required to have an enhanced DBS check in line with the Government’s Keeping Children Safe in Education guidelines (2014)"
【问题讨论】:
-
var_dump($job['description']); -
空格不能是制表符吗?而不是一个空间。我们尝试删除空格,但实际上有一个选项卡。
-
不可重现,eval.in/652084; eval.in/652085。也许空格是实体?
-
需要查看初始 $job['description'] 中的内容 将其打印到文本区域可能会显示浏览器通常隐藏的字符。
<textarea><?=$job['description']?></textarea> -
您可能在某处有一些不可见的字符(不间断空格)。又名 unicode。