getPath());unset($CatPath[0],$CatPath[1]);/*This pulls paths for the categories to make breadcrumbs*/
$breadcrumbsArray = array();/*create an empty array to be filled*/
$paths = array_values($CatPath);/*re-number the array of ID's to start at 0*/
for ($x = 1; $x < count($paths); $x++) {/*starting at 1, while x is less than the #of ID's in paths, repeat until done */
$breadcrumbsArray[] = array( /*fill the array with each of these:*/
"name" => Mage::getModel('catalog/category')->load($paths[$x])->getName(),
"id" => $paths[$x],
"desc" => Mage::getModel('catalog/category')->load($paths[$x-1])->getDescription(), /*$x-1 was needed to compensate for desc not being aligned with category name in admin*/
"previd" => $paths[$x-1]/*this $x-1 is so the clear selection buttons always takes you to the previous selection*/
); /*end of $breadcrumbsArray[]*/
} /*end of for ($x = 1... */
/* This is for debugging the breadcrumbs arrays
echo "paths =
"; var_dump($paths); echo "
"; echo"
"; //paths is only the ID's
echo "breadcrumbs="; var_dump($breadcrumbsArray); echo "
"; echo"
"; //breadcrumbs pulls in the name, id, and desc from paths
*/ ?>
$pathData){/*foreach ID, Name, Description, and prevID*/
?>
?cat=" title="Remove This Item" class="btn-remove">Remove This Item
";echo"
";// Outputs: Baseball
echo $sports[1]; echo"
";echo"
";// Outputs: Cricket
// Associative array
$cities = array("France"=>"Paris", "India"=>"Mumbai", "UK"=>"London", "USA"=>"New York");
echo $cities["France"]; echo"
";echo"
"; // Outputs: Paris
echo $cities["USA"]; echo"
";echo"
"; // Outputs: New York
// Multidimensional array
$superheroes = array(
array(
"name" => "Peter Parker",
"character" => "Spider-Man",
),
array(
"name" => "Tony Stark",
"character" => "Iron-Man",
),
array(
"name" => "Clark Kent",
"character" => "Super-Man",
)
);
echo $superheroes[0]["name"]; echo"
";echo"
";// Outputs: Peter Parker
echo $superheroes[1]["character"]; echo"
";echo"
";// Outputs: Iron-Man
if var_dump($array) shows ' string(0) "" '
You most-likely have html tags in your string that are being rendered by the browser.
$foo = "![]()
";
var_dump($foo); // string(20) ""
//Foreach items:
$z = array(1,2,3);
$x = array();
foreach($z as $y) {
$x[] = $y;
echo "y " . $y;
}
echo ""; var_dump($z); echo "
";
echo ""; var_dump($x); echo "
";
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
$cars = array
(
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
for ($row = 0; $row < 4; $row++) {
echo "Row number $row
";
echo "";
for ($col = 0; $col < 3; $col++) {
echo "- ".$cars[$row][$col]."
";
}
echo "
";
}
Will echo:
Row number 0
Volvo
22
18
Row number 1
BMW
15
13
Row number 2
Saab
5
2
Row number 3
Land Rover
17
15
?>
"Peter Parker",
"character" => "Spider-Man",
),
array(
"name" => "Tony Stark",
"character" => "Iron-Man",
),
array(
"name" => "Clark Kent",
"character" => "Super-Man",
)
);
//Formatting array outputs
echo ""; var_export($superheroes);echo "
"; echo"
";echo"
";
array (
0 =>
array (
'name' => 'Peter Parker',
'character' => 'SpiderMan',
),
1 =>
array (
'name' => 'Tony Stark',
'character' => 'IronMan',
),
2 =>
array (
'name' => 'Clark Kent',
'character' => 'SuperMan',
),
)
echo ""; print_r($superheroes); echo "
"; echo"
";echo"
";
Array
(
[0] => Array
(
[name] => Peter Parker
[character] => SpiderMan
)
[1] => Array
(
[name] => Tony Stark
[character] => IronMan
)
[2] => Array
(
[name] => Clark Kent
[character] => SuperMan
)
)
echo ""; var_dump($superheroes); echo "
"; echo"
";echo"
";
array(3) {
[0]=>
array(2) {
["name"]=>
string(12) "Peter Parker"
["character"]=>
string(9) "SpiderMan"
}
[1]=>
array(2) {
["name"]=>
string(10) "Tony Stark"
["character"]=>
string(7) "IronMan"
}
[2]=>
array(2) {
["name"]=>
string(10) "Clark Kent"
["character"]=>
string(8) "SuperMan"
}
}
?>