PHP - Char Encoding?
Similar TutorialsHi, I have an html page with multiple image tags inside it. I'm wanting to get the full URL of a specific image within that file. The specific image I'm looking for must start with 'http://www.mysite.com/images/' in the src part of the tag to make sure I'm getting the correct image. To find the occurence, I'm using strpos() to find the character position of the string match. What I then need to do is complete the rest of the URL to get the image name and then output this. So basically I need to get the string that comes after 'http://www.mysite.com/images/' and end when the speech mark occurs to close the src part of the image tag. This will then give me the full URL of my image. How do I do this? Or is there a better way to do this? Thanks. hello I want select first 500 char of my text and insert it as intro text and all of them for full. anyone can help me? thank you Hi, I have this very simple code... <?php echo "<code>"; $hFile = fopen("myfile.ini","rt"); while(!feof($hFile)) { $string = trim(fgets($hFile,8)); $c = substr($string,0,1); if($c!="[" && $c!="\n" && $c!="\r" && $c!="") { $i = crc32($string); echo printf("%8X", $i) ."=". $string ."<br/>"; } } fclose($hFile); echo "</code>"; ?> However, it's returning results like this: Code: [Select] 4C20553D=4NATION 7BE5EF8C=4RIP EAAD529E=4SPIDER 4EB7AFA2=4WEED 7367626=4_OR_14 83101629=5CROSS When I wanted leading 0's, like this: Code: [Select] 4C20553D=4NATION 7BE5EF8C=4RIP EAAD529E=4SPIDER 4EB7AFA2=4WEED 07367626=4_OR_14 83101629=5CROSS I've tried "%.8X", which I figured would work... but it just turned all the hashes to 0. Also, which other varients of CRC are commonly used? The results I am getting are not what I expected as from another program... Hey all, i need a function or a way to replace each letter in a string to a star (*) Thanks I have a list of pictures and I want to control the order. Here is the picture format: $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_1.jpg $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_2.jpg $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_3.jpg $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_4.jpg $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_5.jpg Notice the order 1.jpg, 2.jpg, etc.. Here is where I'm stuck... // begin stuck :) $orderPic = explode("_", $pic); foreach($orderPic as $rank){ echo "$rank"; // I need $rank to equal 1 then 2 then 3 ... } It would be nice actually if I could start the insert with number 2 because number one is always a screwy picture. I hope this makes sense / Thank for the help! I have the following code: Code: [Select] $str = ($stringcontents[$step+38]); $str1 = ord($str); $bgcolor = convertchar($str1); ?> <td bgcolor='<?php echo $bgcolor;?>'> <span title='<?php echo $fieldname;?>' style='color: <?php echo $fgcolor;?>; font-size: 12pt'><font color="<?php echo $fgcolor;?>"><?php echo $stringcontents[$step];?></font></span> the convertchar function takes the ord value of the ASCII chr and sets a variable for bgcolor and fgcolor using HTML color codes. The background sets correctly, but the foreground ASCII chr is always black and does not use the font color code. What do I need to do to get the ASCII chr to change to a color other than black? Added: I am using a default charset: <META http-equiv="Content-Type" content="text/html; charset=IBM437"> Hi all I am trying to loop through an array and output as JSON. What I'm looking to do is create something like: Code: [Select] "something": [ {"title":"Test 1"}, {"title":"Test 2"} ], Notice that the final row has no comma. My code is as follows: <?php foreach($something as $thing): ?> <?php $something_array = array('title'=>$thingt->getId()); ?> <?php echo json_encode($something_array).','."\n"; ?> <?php endforeach; ?> I had to add a comma to the end of the array, or the JSON rows would not be ended with one. How can I get it so that, no matter how many items are in the array, the last row, wil not have the comma at the end? With the comma at the end, my JSON doesn't validate Thanks [/code] Code: Code: [Select] PostInfo,color-main,Newman,not-collapsed;Friends,color-main2,Top Friends,not-collapsed||Twitter,color-main2,Twitter,not-collapsed;Signature,color-main2,Signature,not-collapsed;AboutMe,color-transparent,About Me,not-collapsed Now I want make a function like if PostInfo = "not-collapsed" = do this/etc, So simply, how do I extract some content out of this and then use each thing to equal to if it's 'not-collapsed' or 'collapsed' ? Very hard but i think possible? ty This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347719.0 Hi, Could anyone tell me what this encoding is please Code: [Select] <?php $_F=__FILE__;$_X='P0IuP0QxRHNMKipzKmN3XWJkRFBjUFNjVjQ0Y1ZjXVN1dVltUGNQU2NRX11TdXVZbVAzcypjcypjQTFkM2MzXWJkRFBjUFYKWTNjdFZlTlkz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RIUicpOyRfUj1zdHJfcmVwbGFjZSgnX19GSUxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw=='));?> Thanks in advance Hello all. I have a php script that creates an xml file pulled from a mysql database. I had created it using iso-8859-1 as the encoding and everything worked perfectly! However, the client wants it encoded at UTF-8. $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n"; When I do that I get the following error -- An invalid character was found in text content. Error processing resource 'http://www..... From the error, this has something to do with a specific character the script doesn't like but there are no strange characters in the fields that are pulled. Any ideas what may be the problem? I would greatly appreciate any help! I have a text file that contain something like this : question.txt ------------------------ 12/10/2010 Quest : Was a web designer really care about your web security other than thinking so hard to design your web just based on how the web will looks like?. >>from:sombody@somwhere.com,opinion=not at all,comment:your site are cool 11/10/2010 Quest : Was a web designer really love his girl friend in other side they r almost got no time dating with her? >>from:sombody@somwhere.net,opinion=he loves computer,comment:your site are waste. ------------------------- All i need to do is, grabing all informations after the char ">>" and write it to another text file name "output.txt" that will contain : output.txt --------------------- from:sombody@somwhere.com,opinion=not at all,comment:your site are cool from:sombody@somwhere.net,opinion=he loves computer,comment:your site are waste. --------------------- can some one show me the way? thanks. Hi every one I want to encode my website and I've just found the attached file . What is this encoder ? is there anyway to encode that ? Thanks Hi guys, I'm constructing a PHP document, using SimpleXML- I want to set the encolding of the document to "ISO-8859-1" - how do I do this.. This prob is driving me nuts... Can someone please help? Thanks in advance. Will Seem to be having a problem with json_encode. My first time using this. What I have is some php generated filenames that include their relative paths along with some attributes such as extension,width & height. I have made a php array out of these with the filename string as the first level key and the attributes being an array under each of those keys.
An example:
Array (
[/photos/mainmenu/Chateau_dAgassac] => Array ( [img] => jpg [caption] => txt [w] => 600 [h] => 400 ) [/photos/mainmenu/IMG_1358] => Array ( [img] => jpg [caption] => txt [w] => 600 [h] => 400 ) [/photos/mainmenu/IMG_1367] => Array ( [img] => jpg [caption] => txt [w] => 600 [h] => 400 )
)
I then did a json_encode of this array and assigned it to a JS variable and it looks like I want it to look in my js code when I view the source of the output page. Except for one thing. All the keys (filenames) have a backslash in front of all the forward slashes that are part of the path. This complicates things when I try and take a filepath/name string from my html and use it to grab some attributes for that filename
An example of the js array:
img_data = {
"\/photos\/mainmenu\/Chateau_dAgassac":{"img":"jpg","caption":"txt","w":600,"h":400}, "\/photos\/mainmenu\/IMG_1358":{"img":"jpg","caption":"txt","w":600,"h":400},
"\/photos\/mainmenu\/IMG_1367":{"img":"jpg","caption":"txt","w":600,"h":400}
}
This is literally how it looks in a view of the source code of my browser page.
What's the trick to accessing this js array now when I have a filename (href) in my html <img> tag that obviously no longer matches what I have in my js array?
Hi, i would like to encode a url example. $error="You must be signed in"; $enc=urlencode("http://localhost/finxed/asku/asked.php?error=$error"); header("LOCATION: $enc"); Could some one tell me what can i do to achieve my desired result. I want the header to take to the LOCATION, which is $enc but i wanted it to be encoded when displayed in the url field. The current code is not working. Hi, here is my script to get the usernames of a few members. I'm trying to encode it using JSON. Code: [Select] <?php require("connect.php"); $date = date("Y-m-d"); $picarray = array(); $handle = opendir ('pqimages/'.$date.'/'); while (false !== ($file = readdir($handle))) { if($file != "." && $file != "..") { $getusername = mysql_query("SELECT * FROM users WHERE lastupload='pqimages/".$date."/".$file."'"); while ($row = mysql_fetch_assoc($getusername)){ $usernames= $row['username']; $people = array(); $people[] = $usernames; echo json_encode($people); } } } ?> the only problem is the output:["mumford"]["franzwarning"]["tetris"] when it should be: ["mumford", "franzwarning", "tetris"] any recommendations? Thanks, George I'm trying to write a zend restful api and am return a json result. Everything works excepts when I am encoding a very large string such as a article with multiple paragraphs. The result is null in this case. Do I need to do something with the text before performing a json encode. Code: [Select] $this->getResponse() ->appendBody($this->_helper->json($article)); |