is there a character array in php i want to display only first 100 characters in a string how can i do that i am not able to do it using arrays as i use in c/c++ . Also how can i search for a particular letter in a variable. example in http:// www. imobilecentral .be/ and www. imobilecentral . be/ how can i search for http:// and replace if i want
First 100 characters. $string = 'a very long string here....'; echo substr($string, 0, 100); PHP: As for the other, you can do. $domain = preg_replace('/https?:\/\/', 'replace with whatever', $domain); PHP:
Actually, a string is an array. $string = 'a very long string here....'; echo $string[0]; echo $string[2]; Code (markup): This prints "av" to the screen. In the end, you will find string manipulation is a lot easier than under C/C++ and that you can replicate all the functionality you are used to.
thanks for the previous answer. i think i am asking too silly questions. i need to dust my programming books. so what is the difference between preg_replace and str_replace
preg_replace() allows regular expressions while str_replace() doesn't. http://us2.php.net/manual/en/function.preg-replace.php