java array to string_数组到字符串转换(Array to string conversion)
數組到字符串轉換(Array to string conversion)
這段代碼有什么問題? 我不明白。 這是錯誤代碼:
注意:第12行的C:\ xampp \ htdocs \ stage \ ripper.php中的數組到字符串轉換數組塊引用
注意:第13行數組中C:\ xampp \ htdocs \ stage \ ripper.php中的數組到字符串轉換
header('Content-Type: text/html; charset=utf-8');
$url = "http://www.asaphshop.nl/epages/asaphnl.sf/nl_NL/ObjectPath=/Shops/asaphnl/Products/80203122";
$htmlcode = file_get_contents($url);
$pattern = "/itemprop=\"description\"\>(.*)\(.*)\
Taal:(.*)\(.*)\>(.*)\\(.*)\data-src-l\/sU";preg_match_all($pattern, $htmlcode, $matches);
Print_r ($matches);
$description =($matches[1]);
$language = ($matches[3]);
echo $description;
echo $language
?>
What's the problem of this code? I don't get it. This is the error code:
Notice: Array to string conversion in C:\xampp\htdocs\stage\ripper.php on line 12 Array Blockquote
Notice: Array to string conversion in C:\xampp\htdocs\stage\ripper.php on line 13 Array
header('Content-Type: text/html; charset=utf-8');
$url = "http://www.asaphshop.nl/epages/asaphnl.sf/nl_NL/ObjectPath=/Shops/asaphnl/Products/80203122";
$htmlcode = file_get_contents($url);
$pattern = "/itemprop=\"description\"\>(.*)\(.*)\
Taal:(.*)\(.*)\>(.*)\\(.*)\data-src-l\/sU";preg_match_all($pattern, $htmlcode, $matches);
Print_r ($matches);
$description =($matches[1]);
$language = ($matches[3]);
echo $description;
echo $language
?>
原文:https://stackoverflow.com/questions/26377015
更新時間:2020-02-29 18:37
最滿意答案
當您使用preg_match_all , $matches是一個二維數組。 所以$matches[1]和$matches[3]都是數組。 echo僅適用于數字或字符串,因此當您嘗試回顯數組時會收到警告。 如果要查看其中的內容,請使用print_r()或var_dump() :
print_r($description);
print_r($language);
When you use preg_match_all, $matches is a 2-dimensional array. So $matches[1] and $matches[3] are both arrays. echo only works with numbers or strings, so you get a warning when you try to echo an array. If you want to see what's in them, use print_r() or var_dump():
print_r($description);
print_r($language);
2014-10-15
相關問答
對我來說似乎完全合法; char *[3]衰變為char ** ,所以賦值應該是有效的。 GCC 4.4.5和CLang 1.1都沒有抱怨。 Seems perfectly legal to me; char *[3] decays to char **, so the assignment should be valid. Neither GCC 4.4.5 nor CLang 1.1 complains.
要開始你的作業, String.split將正則表達式分割字符串,此表達式可能是一個空字符串: String[] ary = "abc".split("");
產生數組: (java.lang.String[]) [, a, b, c]
擺脫空的第一個條目留給讀者練習:-) 注意:在Java 8中,不再包含空的第一個元素。 To start you off on your assignment, String.split splits strings on a regular expressi
...
serialize數據:
然后反unserialize : <?php
$youralldata = unserialize($_POST['data']);
print_r($youralldata);
?>
serialize the data:
...
the_given_string.scan(/"(.*?)"/).flatten
the_given_string.scan(/"(.*?)"/).flatten
$list = array ($_POST["array"]);
如果$_POST['array']已經是一個數組, Array($_POST['array'])將產生[一個]數組字符串數組。 如果你寫print_r($list) ,你會看到類似這樣的東西: Array(0 =>
Array(
0 => "0",
1 => "0",
2 => "0",
3 => "0",
4 => "0",
5 => "0",
6 => "0",
7 => "0
...
你在char[]上調用toString并繼承Object的實現,所以你得到了char[].class名字,然后是對象的哈希。 相反,調用String(char[])構造函數: nid_txt.setText(new String(emp.nid));
You're calling toString on a char[] - and that inherits the implementation from Object, so you get the char[].class name, @
...
你只需要使用正確的字符串連接。 改變這一行: echo "";
對于其中一個選項: echo "";
echo "";
希望能幫助到你。 You just need to use proper string concatenation. Change
...
您收到錯誤,因為$pages是一個數組。 看起來你想要吐出該數組中的項目數,在這種情況下你應該用count($pages)替換$pages 。 echo '
', $prevlink, ' Page ', $page, ' of ',
count($pages), ' pages, displaying ', $start, '-', $end, ' of ', count($total),
'results ', $nextlink,
...
當您使用preg_match_all , $matches是一個二維數組。 所以$matches[1]和$matches[3]都是數組。 echo僅適用于數字或字符串,因此當您嘗試回顯數組時會收到警告。 如果要查看其中的內容,請使用print_r()或var_dump() : print_r($description);
print_r($language);
When you use preg_match_all, $matches is a 2-dimensional array. So $
...
你這樣做: echo'
(line 248) '.$ids = array();
基本上,您不能將數組與字符串連接,這就是出現錯誤的原因。 要修復錯誤,可以將數組聲明分隔為單獨的行: echo'
';$ids = array();
希望這可以幫助! You're doing this: echo'
(line 248) '.$ids = array();
Basically, you can'
...
總結
以上是生活随笔為你收集整理的java array to string_数组到字符串转换(Array to string conversion)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql+create+table+i
- 下一篇: java 16进制与汉字_java实现汉