Archivo de la etiqueta: cadena
str_replace for a utf8 string
str = "asd€aaa";
$str = str_replace("€","",$str);
Not replacing the € sign for some reason.
Tengo mb_internal_encoding("UTF-8");… set up at the top of the file (which is saved in UTF-8).
The string originates from a MySQL db, so I also Sigue leyendo
How can you get the replaced text with preg_replace?
I am using the preg_replace function in PHP and am trying to replace urls that users submit with bit.ly shortened links:
$comment = preg_replace( '/(http|ftp)+(s)?:(//)((w|.)+)(/)?(S+)?/i', '', $strText );
…
This will show only the comment and “wipe out” the url. La Sigue leyendo
Regexp ignore certain parts in string
I need to use regex for a string to find matching results.
I need to find the (.+?) but would like to ignore everything where it says (*) ahora mismo:
$regex='#<span class="(*)"><a href="/venues/(*)">(.+?)</a></span>#';
…
Instead of ignoring (* ), it echoes Sigue leyendo
Why wont all of this string print?
I am just trying to generate a path with something like :
$PhotoName = the_title();
$DestinationFile = 'temp/watermarked/';
$DestinationFile .= $PhotoName;
$DestinationFile .= '.jpg';
the_title(); is a WordPress function that gets the title of the post. Si echo… sólo Sigue leyendo
Rotate a string N times in PHP
I’m looking for a way to rotate a string to the left N times. Estos son algunos ejemplos:
Let the string be abcdef
if I rotate it 1 time I want
bcdefa
if I rotate it 2… time I want Sigue leyendo
Process string with special characters in PHP
I got an string like:
M%C3%B2nica
So I need to get something like “Mònica”.
Which is the better way in PHP?… Sigue leyendo
How to check whether StringB starts with StringA in PHP?
How can you check whether StringB starts with StringA if the length of both is variable…? Sigue leyendo
PHP – How do I generate strings with control characters or binary data?
For testing purposes I need strings such as:
"testx00string"
…
I would like to loop over the control characters (00-1F) and generate the strings automatically so I don’t have to clutter my code with 31 lines like this but don’t know Sigue leyendo
Php – Remove repeated words in a string
Entrada: ball ball code
Output should be: ball code
Entrada: awycodeawy
Output should be: awycode
I tried these, but didn’t work:
$q = preg_replace("/s(w+s)1/i", "$1", $q);
$q = preg_replace("/s(w+s)1/i", "$1", $q);
…
PHP variables not being displayed between ajax call (kindof?)
I have a system laid out such that when a user hits a button the system makes an ajax call to another PHP page which contains a form and that PHP page echo’s it back to the current php page… Sigue leyendo





