Forum Moderators: coopster
I'd like to just convert the string in the script from UTF-8 to whatever charset defined in the script, but I haven't figured out how to do that. Ideally the script would get the encoding used by the current page but I don't think that would be possible if the PHP script is included into another, which is it's main application.
I've tried using the iconv_get_encoding, iconv_set_encoding and mb_convert_encoding functions, all of them give me an error that they are undefined. This is strange because I use PHP version 4.3.10, so the functions are supported in this release.
On an unrelated problem I've spent some time over, I need to download a single line of an offsite HTML file, perhaps using curl or wget? I looked through the options a couple of times but maybe I've missed something, starting at an offset won't work because the above lines will have varied lengths.
unrelated problem: you could simply use
file()if you have url wrappers on - it will put the file into an array line-by-line.
file_get_contents()will just put it all into a single variable.
On the unrelated problem, at the moment I use file_get_contents() to get the html file, then use awk to get the line I need (it's faster than PHP). The problem is that it is quite large and I just want to get one line from the file. With curl it's possible to get a specific offset but with varying sizes of lines above the one I want, it wouldn't work.