If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
array_unshift() method का use एक या एक से अधिक values को Array में prepend (Add) करने के लिए किया जाता है। Prepend होने वाली values Array के starting में insert होती हैं।
array_unshift(array $array , mixed ...$values );
array $array | required : Input Array जिसमे new values prepend करना चाहते हैं।
mixed $value | required : $value , input value है जिसे Array में prepend करना है। input value mixed type की हो सकती है। आप कितनी ही values pass कर सकते हैं insert करने के लिए , लेकिन कम से कम एक तो होनी ही चाहिए।
mixed type का मतलब होता है , कि आप अपनी need के according किसी भी type (String , Boolean , Array , Class , Numeric) की value pass कर सकते हैं। यह जरूरी नहीं है कि कोई special type की value ही pass करें।
Return Value : value append होने के बाद Array Length return करता है।
File : php_array_unshift.php
<?php
$stack = array("orange", "banana");
echo array_unshift($stack, "apple", "raspberry");
echo "<pre>";
print_r($stack);
echo "</pre>";
?>
4 Array ( [0] => apple [1] => raspberry [2] => orange [3] => banana )
? array_unshift() function में pass किया गया पहला argument अगर Array नहीं है तो warning error आएगी।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook