[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: в не if и в if разный результат
DarkGuy
Добрый день!
Почему выдает разный результат?

echo '<pre>'.print_r($array['GAME']).'</pre>';
if($_POST['start'] == '1'){
echo '<pre>'.print_r($array['GAME']).'</pre>';
}


в первом случае выдает нормальный результат
Array ( [1] => Array ( [id] => 1 [name] => Alan Wake [price] => 450 [number] => 3 [Platform] => Windows ) [2] => Array ( [id] => 2 [name] => Alan Wake. Коллекционное издание [price] => 1000 [number] => 2 [Platform] => Windows ) )
во втором
1
Winston
Потому что вторым аргументом для print_r нужно передать true
DarkGuy
Цитата (Winston @ 27.10.2012 - 17:15)
Потому что вторым аргументом для print_r нужно передать true

echo '<pre>'.print_r($array['GAME']).'</pre>';
if($_POST['start'] == '1'){
echo '<pre>'.print_r($array['GAME'], true).'</pre>';
}


выдает такой же результат
Winston
Ну так ты только для ОДНОГО print_r передал true, а для первого так и не передал...
DarkGuy
Цитата (Winston @ 27.10.2012 - 17:23)
Ну так ты только для ОДНОГО print_r передал true, а для первого так и не передал...

echo '<pre>'.print_r($array['GAME'], true).'</pre>';
if($_POST['start'] == '1'){
echo '<pre>'.print_r($array['GAME'], true).'</pre>';
}


выдает только результат echo '<pre>'.print_r($array['GAME'], true).'</pre>'; первого, а второго нет.
DarkGuy
т.е. только Array ( [1] => Array ( [id] => 1 [name] => Alan Wake [price] => 450 [number] => 3 [Platform] => Windows ) [2] => Array ( [id] => 2 [name] => Alan Wake. Коллекционное издание [price] => 1000 [number] => 2 [Platform] => Windows ) )
Winston
Весь код покажи, а не какие то вырванные куски
DarkGuy
Цитата (Winston @ 27.10.2012 - 17:27)
Весь код покажи, а не какие то вырванные куски

<?php //setCookie("GAME","");
echo'
<head>
<link rel="stylesheet" href="http://test_namber_356898.z247672.infobox.ru/thems/Virtex/css/stylecart.css" ; type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->

<!--<script type="text/javascript" src="http://test_namber_356898.z247672.infobox.ru/thems/Virtex/jquery.js">< /script>
<script type="text/javascript" src="http://test_namber_356898.z247672.infobox.ru/thems/Virtex/script.js">< /script>-->
</head>
<div class="cart"><div id="cart-main">
<div class="cleared reset-box"></div>
<div class="cart-box cart-sheet">
<div class="cart-box-body cart-sheet-body">
<div class="cart-layout-wrapper">
<div class="cart-content-layout">
<div class="cart-content-layout-row">
<div class="cart-layout-cell cart-content">
<div class="cart-box cart-post">
<div class="cart-box-body cart-post-body">
<div class="cart-post-inner cart-article">
<h2 class="cart-postheader">Корзина
</h2>
<div class="cart-postcontent">

<form method="POST" name="orkicart">
<table class="cart-article" border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td style="text-align: center;">img</td>

<td style="text-align: center;">название</td>

<td style="text-align: center;">Тип</td>

<td style="text-align: center;">Платфорама</td>

<td style="text-align: center;">Цена</td>

<td style="text-align: center;">Колличество</td>

<td style="text-align: center;">Сумма</td>

<td style="text-align: center;">Удалить</td>
</tr>'
;



$buy_all= 0;
if(isset($_COOKIE['GAME'])){

//print_r($_COOKIE);
$json=$_COOKIE['GAME'];
// echo $json;
$array = json_decode($json, true);

//echo '<pre>'.print_r($array, true).'</pre>';

foreach($array['GAME'] as $index2 => $val2){
// echo($index2."->".$val2." <br>");
$array['GAME'][$index2][name];


echo' <tr>
<td style="text-align: center;"><img width="30" height="30" alt="" src="http://test_namber_356898.z247672.infobox.ru/thems/Virtex/imagescart/game.png&quo t; /><br /></td>

<td style="text-align: center; vertical-align: middle;">'
.$array['GAME'][$index2][name].'</td>

<td style="text-align: center; vertical-align: middle;">Key</td>

<td style="text-align: center; vertical-align: middle;">'
.$array['GAME'][$index2][Platform].'</td>

<td style="text-align: center; vertical-align: middle;">'
.$array['GAME'][$index2][price].'</td>';
$buy_all_num =($array['GAME'][$index2][price]*$array['GAME'][$index2][number]);
$buy_all= ($buy_all+$buy_all_num);
echo'<td style="text-align: center; vertical-align: middle;"><input name="id_kolvo_'.$array['GAME'][$index2][id].'" value="'.$array['GAME'][$index2][id].'" type="hidden" ><input name="kolvo_'.$array['GAME'][$index2][id].'" onkeyup="if (this.value!=this.value.replace(/\D/gi, \'\')) {alert(\'Орки не любят -'.$array['GAME'][$index2][number].'!\'); this.value=this.value.replace(/\D/gi, \'\');}" id="kolvo" type="text" size="3" maxlength="3" rel="'.$buy_all.'" value="'.$array['GAME'][$index2][number].'"></td>';

echo'<td style="text-align: center; vertical-align: middle;">'.$buy_all_num.'</td>
'
;$buy_all_num = 0;
echo'<td style="text-align: center; vertical-align: middle;"><img width="20" height="20" id="'.$array['GAME'][$index2]['id'].'" alt="" src="http://test_namber_356898.z247672.infobox.ru/thems/Virtex/imagescart/delete.png&q uot; rel="'.$array['GAME'][$index2][price].'" /><br /></td>
</tr>'
;


}
$wheremymoney = 1;
echo'<input name="start" value="'.$wheremymoney.'" type="hidden" >';



echo '<pre>'.print_r($array['GAME'], true).'</pre>';
if($_POST['start'] == '1'){
echo '<pre>'.print_r($array['GAME'], true).'</pre>';

foreach($array['GAME'] as $index6 => $val6){ $array['GAME'][$index6][number] = $_POST['kolvo_'.$array['GAME'][$index6][id]];}
$array = json_encode($array['GAME']);
setcookie('GAME', ''.$array.'',time()+(604800));
$wheremymoney++;
}

echo'</tbody>
</table><br />'
;


echo'<p> Общаяя сумма <div class="all_price">'.$buy_all.'</div> рублей.</p>

<p style="text-align: center;"> <input type="submit" value="Пересчитать" class="cart-button cart-button"> <span class="cart-button-wrapper"><span class="cart-button-l"> </span><span class="cart-button-r"> </span><a href="#" class="cart-button cart-button">Купить!</a></span> </p>
</form>
</div>
<div class="cleared"></div>
</div>

<div class="cleared"></div>
</div>
</div>

<div class="cleared"></div>
</div>
</div>
</div>
</div>
<div class="cleared"></div>
<div class="cart-footer">
<div class="cart-footer-body">
<div class="cart-footer-text">
<p>Copyright © 2012. All Rights Reserved.</p>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
</div>
</div>'
;

}

echo'</div>';
//print_r($_POST);
// echo '<pre>'.print_r($array['GAME']).'</pre>';

/*
$json2 = $_COOKIE['GAME'];
echo $json2;
$array2 = json_decode($json2, true);*/
// echo '<pre>'.print_r($_POST).'</pre>';
// echo '<pre>'.print_r($array, true).'</pre>';



?>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.