Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I need a method that concatenate string with enter. As an example my string "Apple", "Box".
That string needs to be as:
$mynewstring = "Apple
Box"
Not as:
$mynewstring ="Apple "."\n"."Box" or $mynewstring ="Apple "."<br>"."Box"
Please tell how to do this.
Just do like this..
<?php
$mynewstring = "Apple,Box";
$arr=explode(",",$mynewstring);
echo(implode(PHP_EOL,$arr));
OUTPUT :
Apple
Box
If your variable is a part of DOM(browser related operation), then consider using <br/>, and use \n if using with php CLI.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Could somebody tell me the regular expression for replacing everything outside of quote marks with white space?
Example text :
permalink_title='$permalink_title',
code_size_3='$code_size_3',
code_size_3='$code_size_3',
code_size_35='$code_size_35',
code_size_4='$code_size_4',
code_size_45='$code_size_45',
code_size_5='$code_size_5',
code_size_55='$code_size_55',
code_size_6='$code_size_6',
code_size_65='$code_size_65',
code_size_7='$code_size_7',
code_size_75='$code_size_75',
code_size_8='$code_size_8',
code_size_85='$code_size_85',
code_size_9='$code_size_9',
code_size_95='$code_size_95',
code_size_10='$code_size_10',
code_size_105='$code_size_105',
So the expression would replace everything outside of '$permalink_title' with whitespace. Ideally it would go one better and replace everything with whitespace leaving only the PHP variable - $permalink_title
*Note - I was going to perform this function with Komodo Edit or Notepad++
Any help would be great.
Use this regex :
(^[^']+|(?<=')[^']+$)
Debuggex Demo
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I would like to parse a string and get characters from the end back to the first slash in the string. The string may change.
An example may be:
'string4\string3\string2\string1'
And I would want string1 from this example.
Another example string is:
'string3\string2\string1'
And I would like to get string1 from this example. Can this be done in php using regular expressions?
Just break the string apart by the \ character and get the last part:
$parts = explode('\\', $string);
echo $parts[count($parts) - 1];
Demo
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I need to search word like 'Galaxy S Duos' using search keyword 'galaxysduos'. Kindly provide me the solution in PHP Mysql Query.
SELECT * FROM yourTable WHERE REPLACE(fieldname," ","")="galaxysduos"
try this added some modifiction of #Hanky's answer
SELECT * FROM `yout_table` WHERE LOWER(REPLACE(`your_field`," ",""))="galaxysduos"
OR
SELECT * FROM `yout_table` WHERE REPLACE(LOWER(`your_field`)," ","")="galaxysduos"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Hello I have an array in PHP when I print it it is like that :
["Testing","Test2","New Testing Activity","The last five letters in the alphabet"]
is there a way to make the array like that :
{"Testing","Test2","New Testing Activity","The last five letters in the alphabet"}
I want this '{' instead of '['
Thanks
Maybe you want to do:
echo '{"' . implode('","', $arr) . '"}';
Demo: http://phpfiddle.org/lite/code/p57-0u4
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Is there any way that I can get o identify characters like(trademark, superscripts, numbers) from text or text file(but these characters are't in HTML code) and replace them using php
Example:
Get from text: ™ replace with PHP: (TM)
Yes, just parse your strings with str_replace.
Note that str_replace can use arrays, so you can replace multiple strings at once:
$text = "Text™®";
$text = str_replace(['™', '®'], ['(TM)', '(R)'], $text);
print $text;