Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I would like to uplaod files using cURL but can't figure out how I can use $url array.
For example:
$urls = array("http://images.domain.com/",
"http://flash.domain.com/",
"http://other.domain.com/"
);
foreach ($urls as $url) {
I'm trying this but without success:
$upload = "$url ."upload/upload.php";
Any advice? :)
Thanks
You need to take out the first quote for it to work
$urls = array("http://images.domain.com/",
"http://flash.domain.com/",
"http://other.domain.com/"
);
foreach ($urls as $url) {
$upload = $url ."upload/upload.php";
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Have code:
$url = 'http://www.domain.com/dir1/dir2/dir3/page-2.html';
if ($strpos = strpos('/page', $url)) echo '1';
else echo '2';
It shows only '2'.
How can I fix it?
Change arguments places
strpos($url, '/page')
strpos
Actually the syntax for function was mismatched I think.
use this
$stropos = stripos($url,"/page");
echo $strpos;
Please add === identical compare in if condition and correct the position of strpos parameters
$url = 'http://www.domain.com/dir1/dir2/dir3/page-2.html';
if ($strpos == strpos($url, '/page')) echo '1';
else echo '2';
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can anyone help me get the value of IFC/USD 0.00001031 from the webpage http://infinitecoin.com.
I need to grab the value after IFC/USD..
The way I thought to do it was to:
$file_string = file_get_contents('http://infinitecoin.com');
preg_match('/IFC/USD plus next 11 charecters', $file_string, $title);
$value = $title[1];
echo $title_out ;
But im not sure how to ask PHP to find IFC/USD then return the next 11 characters after that.
If I could accomplish this, my task would be solved..
Any help would be great.
Thank you
Jason
$output = array();
preg_match("/(?<=IFC\/USD\s)[\d\.]+/", 'IFC/USD 0.00001015', $output);
$output will look like this:
Array
(
[0] => 0.00001015
)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Hi all i am looking for a simple way to check if a string equals an url like this:
http://youtu.be/WWQZ046NeUA
To convert it to a proper youtube url like this:
http://www.youtube.com/watch?v=WWQZ046NeUA
If not to leave it alone, what's the simplest way to do it in php?
You can use this preg_replace call:
$u = 'http://youtu.be/WWQZ046NeUA';
$r = preg_replace('~^https?://youtu\.be/([a-z\d]+)$~i', 'http://www.youtube.com/watch?v=$1', $u);
str_replace should work wonders.
$url = ''; //url you're checking
$ytshorturl = 'youtu.be/';
$ytlongurl = 'www.youtube.com/watch?v=';
if (strpos($url,$yturl) !== false) {
$url = str_replace($ytshorturl, $ytlongurl, $url);
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I receive data in this format like:
C00001,C00302,C00303,C00287,C00286,C00285,C00017
in a variable but i need in this shape:
'C00001','C00302','C00303','C00287','C00286','C00285','C00017'
i am new in mysql kindly any help
You can explode the data, modify it, then re-implode it.
$data = 'C00001,C00302,C00303,C00287,C00286,C00285,C00017';
$arr = explode(',', $data);
$new_arr = array_map(function($a){
return "'{$a}'";
}, $arr);
$new_data = implode(',', $new_arr);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
So I create a Supermarket class and initiate two objects like this:
$items[0] = new Supermarket("Item1", 2.70);
$items[1] = new Supermarket("Item2", 1.0);
Then I call the showItem() method on the first object of the array and it works:
$items[0]->showItem();
But when I try to use a for or a foreach loop through the array to show all the items I get the non-object error. The following won't work either:
$i = 0;
$items[i]->showItem();
Any ideas?
You are not using the variable sign $
$i = 0;
$items[$i]->showItem();
change like
$i = 0;
$items[i]->showItem();
$i = 0;
$items[$i]->showItem();
$items[$i] instead of $items[i]