Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
hi i want to create string in laravel with foreach and that string must be like this sample:
'item1,item2,item3'
Pay attention to commas and quotation marks.
anyone can help me?
you can use implode function.
Have a look at https://www.php.net/implode
It does exactly that with arrays.
example:
$string = implode(",", $array);
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to remove double quotes from json {"x":"y"} to {x:y} in PHP
If you just need to remove " from a string you can use the str_replace method.
$new_str = str_replace("\"", "", json);
I hope I was helpful.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I got these arrays
$address = array("1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh", "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT", "1dice6YgEVBf88erBFra9BHf6ZMoyvG88")
$amount= array("100000000","150000000","200000000")
and I want to convert them to json format like below:
{
"1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
"12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
"1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}
I tried too much but couldn't figure out how to do that in PHP, any ideas?
Use array_combine:
echo json_encode(array_combine($address, array_map('intval', $amount)));
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Using php+mysql how can i get an item from database with a criteria as shown below.
Check if string lookat(which is 'look at' without space) exist in Take an in-depth look at Wednesday's World Cup semifinal
If you have a lot of data in your table, this wouldn't be ideal. But you could do something like.
WHERE REPLACE(column, " ", "") LIKE "%lookat%"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Please any one help me. As I am a noobe in PHP coding. Is there any built in function to trim letters in PHP??
Lookup substr()
http://us2.php.net/substr
Should do the trick
$var = 'teststring1234567890';
substr($var, 0, -10);
returns 'teststring'
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is it possible to find MUSECMS_WIDGET(NAMEOFWIDGETHERE); and get the NAMEOFWIDGETHERE? And then replace the MUSECMS_WIDGET(NAMEOFWIDGETHERE); with
<!--NAMEOFWIDGETHERE--!>?
Please consider:
http://php.net/manual/en/function.preg-replace.php
If you don't know about regular expressions please read up on them here:
http://www.zytrax.com/tech/web/regex.htm
Here's a simple example:
$var = str_replace("NAMEOFWIDGETHERE", "Your Replacement", $subject);
The $subject is your original String.