mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-27 07:55:49 +03:00
[GH-ISSUE #216] Spotify API - why can't I detect multiplace spaces in array data? #148
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#148
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jan 21, 2021).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/216
Hi Jonathan!
I hope you're well.
I'm using the search method like this:
That works fine and as
'return_assoc' => trueis set, then the data that is returned is in the form of an array.Data returned in the episode description (e.g.
$episodes['items'][0]['description']) can have two spaces in it, which I need to detect so I can replace those with a<br />tag.The issue I have is that I cannot detect those double spaces when the data is returned by the API.
I have a function to replace 2 spaces with
44for testing, and it works fine if I hard-code the string values - e.g.The above returns:
However, if I get the string value from the API - e.g.
Then the double spaces are not detected.
I can't check using the official Spotify API (e.g. using PHP and their API) - I only know how to use the API via your (excellent) library.
I'm not sure if this is a Spotify issue, or a library issue, or a PHP issue?
Any advice much appreciated.
Thanks!
Jim
@jwilsson commented on GitHub (Jan 21, 2021):
Hey Jim!
This is really strange, when I try it it's correctly replacing double spaces. Some things off the top of my head which you can try, though:
preg_replacepart from scratch, sometimes invisible garbage characters sneak in.preg_replacewith\swhich will match all space characters (including tabs and newlines), i.e.preg_replace("/\s{2,}", "44", $episode_desc);.str_replace(" ", "44", $episode_desc)instead, should be faster in this case as well (note the double spaces although GitHub seems to remove them).I don't think it's an API or library issue, but probably something with the text encoding or similiar.
Hope this helps!
Cheers,
Jonathan
@ghost commented on GitHub (Jan 22, 2021):
Hi Jonanthan - thanks for your reply.
I think the issue is probably caused by the fact I'm running the code on IIS on Windows 10.
If I had access to be able to run it on Apache that's running on e.g. Linux, I imagine it'd work okay too.
I have Apache installed on my PC as well, and the same issue happens when I run the code on PHP on Apache too.
I tried your helpful suggestions - thank you - but nothing works.
I guess it's just a limitation of using Windows to deliver PHP content :-)
Thanks again
Jim